R – Loading someone else’s .rdata file, can’t access the data

loadr

My professor has sent me an .rdata file and wants me to do some analysis on the contents. Although I'm decent with R, I've never saved my work in .rdata files, and consequently haven't ever worked with them.

When I try to load the file, it looks like it's working:

> load('/home/swansone/Desktop/anes.rdata')
> ls()
[1] "25383-0001-Data"

But I can't seem to get at the data:

> names("25383-0001-Data")
NULL

I know that there is data in the .rdata file (it's 13 MB, there's definitely a lot in there) Am I doing something wrong? I'm at a loss.

Edit:

I should note, I've also tried not using quotes:

> names(25383-0001-Data)
Error: object "Data" not found

And renaming:

> ls()[1] <- 'nes'
Error in ls()[1] <- "nes" : invalid (NULL) left side of assignment

Best Answer

You're going to run into a lot of issues with an object that doesn't begin with a letter or . and a letter (as mentioned in An Introduction to R).

Use backticks to access this object (the "Names and Identifiers" section of help("`") explains why this works) and assign the object to a new, syntactically validly named object.

Data <- `25383-0001-Data`
Related Topic