Loading someone else's .rdata file, can't access the data

≯℡__Kan透↙ 提交于 2019-12-05 02:08:06

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`

Maybe it has to do with the unusual use of dashes in the name and backquotes work:

names(`25383-0001-Data`)

Edit:

More for reference (since Joshua already answered the main question perfectly), you can also reassign an object from ls() (what Wilduck tried in the question) using get(). This might be useful if the object of the name contains very weird characters:

foo <- 1:5
bar <- get(ls()[1])
bar
[1] 1 2 3 4 5

This of course requires the index of foo in ls() to be [1], but looking up the index of the required object is not too hard.

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