Mengunduh file

Mengimpor Data Tingkat Menengah di R

Filip Schouwenaars

Instructor, DataCamp

Contoh: Excel

library(readxl)

read_excel("http://assets.datacamp.com/course/ importing_data_into_r/cities.xlsx")
Error:
'http://assets.datacamp.com/course/importing_data_into_r/cities.xlsx' 
tidak ada di direktori kerja saat ini.
Mengimpor Data Tingkat Menengah di R

download.file()

url <- "http://assets.datacamp.com/
            course/importing_data_into_r/cities.xlsx"

dest_path <- file.path("~", "local_cities.xlsx")
download.file(url, dest_path)
// Pesan progres unduhan diabaikan
read_excel(dest_path)
    Capital Population
1  New York   16044000
2    Berlin    3433695
3    Madrid    3010492
4 Stockholm    1683713
Mengimpor Data Tingkat Menengah di R

Mengapa download.file()?

  • Reproducibilitas

  • HTTP dari dalam R

    • Otentikasi

    • Parameter tambahan

    • httr - Hadley Wickham

Mengimpor Data Tingkat Menengah di R

Ayo berlatih!

Mengimpor Data Tingkat Menengah di R

Preparing Video For Download...