Loading Rdata files from url

佐手、 提交于 2019-12-10 13:05:31

问题


I'm having difficulty loading a file so that it doesn't lose its dimensions. So here is where I'm at:

> mood_data <- read.table("http://www.psychology.mcmaster.ca/bennett/psy710/datasets/mood_data.Rdata")

If I do this it just gives me all the information disorganized in one line. I also tried:

> mood_data <- url("http://www.psychology.mcmaster.ca/bennett/psy710/datasets/mood_data.Rdata")
> load(mood_data)

If I do this I get this weird stuff that doesn't make any sense to me.


回答1:


You should use load for .RData files. This works for me.

> load(url("http://www.psychology.mcmaster.ca/bennett/psy710/datasets/mood_data.Rdata"))
> ls()
[1] "mood.data"
> head(mood.data)
     group mood
1 pleasant    6
2 pleasant    5
3 pleasant    4
4 pleasant    7
5 pleasant    7
6 pleasant    5


来源:https://stackoverflow.com/questions/26108575/loading-rdata-files-from-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!