11

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.

pogibas
  • 27,303
  • 19
  • 84
  • 117
y3trgfhsfgr
  • 467
  • 8
  • 17

1 Answers1

15

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
Roman Luštrik
  • 69,533
  • 24
  • 154
  • 197
  • This worked perfectly, thank you! One question though, why does "mood.data" become the data frame name? – y3trgfhsfgr Sep 29 '14 at 21:12
  • 2
    @BrettCochrane This was the variable name when `.Rdata` file was created. – Roman Luštrik Sep 30 '14 at 06:05
  • @y3trgfhsfgr an `.Rdata` file is being saved using the `save` function. When it is being saved, this function takes the name of this data as it was parsed to it (its actual name in the global environment). For example `save(myData, file ="...")`. Then, when loaded using `load`, this file is being saved within the global environment under its original name ("myData"). – David Arenburg Mar 07 '15 at 20:08