파일 다운로드

R 데이터 가져오기 중급

Filip Schouwenaars

Instructor, DataCamp

예: Excel

library(readxl)

read_excel("http://assets.datacamp.com/course/ importing_data_into_r/cities.xlsx")
오류:
'http://assets.datacamp.com/course/importing_data_into_r/cities.xlsx' 가(이)
현재 작업 디렉터리에 없습니다.
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)
// 다운로드 진행 메시지는 생략
read_excel(dest_path)
    Capital Population
1  New York   16044000
2    Berlin    3433695
3    Madrid    3010492
4 Stockholm    1683713
R 데이터 가져오기 중급

왜 download.file()?

  • 재현 가능성

  • R 내부에서 HTTP 사용

    • 인증

    • 추가 매개변수

    • httr - Hadley Wickham

R 데이터 가져오기 중급

연습해 봅시다!

R 데이터 가져오기 중급

Preparing Video For Download...