参考 Schouwenaars (2016)
对于在 Web 上的 Excel
download.file
函数,必须指定 dest.file
参数具体参考 Reference。
# Load the readxl and gdata package
library(readxl)
# library(gdata)
# Specification of url: url_xls
url_xls <- "http://s3.amazonaws.com/assets.datacamp.com/production/course_1478/datasets/latitude.xls"
# excel_gdata <- read.xls(url_xls)
download.file(url_xls, destfile = "local_latitude.xls")
library(readxl)
excel_readxl <- read_excel("datasets/latitude.xls")
excel_readxl <- read_excel("datasets/latitude.xlsx")
You can load data from an RData file using the load() function, but this function does not accept a URL string as an argument. In this exercise, you’ll first download the RData file securely, and then import the local data file. DataCamp
也需要下载。
# https URL to the wine RData file.
url_rdata <- "https://s3.amazonaws.com/assets.datacamp.com/production/course_1478/datasets/wine.RData"
# Download the wine file to your working directory
download.file(url_rdata,"wine_local.RData")
# Load the wine data into your workspace using load()
load("wine_local.RData")
# Print out the summary of the wine data
wine
trying URL 'https://s3.amazonaws.com/assets.datacamp.com/production/course_1478/datasets/wine.RData'
InternetOpenUrl failed: '�����������������'Error in download.file(url_rdata, "wine_local.RData") :
cannot open URL 'https://s3.amazonaws.com/assets.datacamp.com/production/course_1478/datasets/wine.RData'
报错。