简体   繁体   English

readRDS中的错误

[英]Error in readRDS

I'm running R v3.4.3 and I see an error when I try to read a publicly available rds file. 我正在运行R v3.4.3,尝试读取公共可用的rds文件时看到错误。

>githubURL<-("https://github.com/ChongWu-Biostat/aSPUpath2/blob/master/Example/example.stat.rds")
>download.file(githubURL,"example.stat.rds", method="curl")
>example.stat<-readRDS("example.stat.rds")
Error in readRDS("example.stat.rds") : unknown input format

That URL points to the web page for that file. 该URL指向该文件的网页。 You've downloaded the HTML and tried to load that as a .RDS. 您已经下载了HTML,并尝试将其作为.RDS加载。 If you look at the .RDS file you'll see. 如果您查看.RDS文件,将会看到。

You really want the URL for the raw data: 您确实想要原始数据的URL:

> url = "https://raw.githubusercontent.com/ChongWu-Biostat/aSPUpath2/master/Example/example.stat.rds"
> download.file(url,"example.stat.rds", method="curl")
[download progress...]
> example.stat<-readRDS("example.stat.rds")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM