因为我无法打开counties.rds
文件,所以我在Shiny Apps Tutorial Lesson 5上挂了。 readRDS()
投掷:error reading from connection
。为什么我需要为这个.rds文件使用mode = wb和download.file()?
我想我可以打开.rds
的罚款,如果我用download.file(URL, dest, mode = "wb")
下载它或只是用我的浏览器下载文件到我的本地目录。
突出的问题:为什么counties.rds
文件无法正常打开,如果我使用download.file()
没有设置mode = "wb"
?我希望答案会是这样的:“Duh,counties.rds
是一个二进制文件。”但是,在我尝试回答自己的问题之前,我希望得到具有更多经验的人员的确认。
摄制步骤:
download.file("http://shiny.rstudio.com/tutorial/lesson5/census-app/data/counties.rds",
"counties.rds")
counties <- readRDS("counties.rds")
Error in readRDS("counties.rds") : error reading from connection
分辨率:经由浏览器下载或使用二进制模式(wb
)。
download.file("http://shiny.rstudio.com/tutorial/lesson5/census-app/data/counties.rds",
"counties.rds", mode = "wb")
counties <- readRDS("counties.rds") # Success!
可能因为“.rds”文件不是文本而是二进制文件。 – 2015-04-23 05:29:49