加载别人的.rdata文件,无法访问数据 [英] Loading someone else's .rdata file, can't access the data

查看:69
本文介绍了加载别人的.rdata文件,无法访问数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的教授给我发送了一个.rdata文件,希望我对内容进行一些分析.尽管我对R相当了解,但我从未将工作保存在.rdata文件中,因此也从未与他们合作.

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

我知道.rdata文件中有数据(它为13 MB,其中肯定有很多)我做错什么了吗?我很茫然.

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.

我应该注意,我也尝试过不使用引号:

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

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

并重命名:

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

推荐答案

对于不是以字母或开头的对象,您将遇到很多问题.和一封信(如中所述R 简介).

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).

使用反引号来访问该对象( help(`")的名称和标识符"部分解释了此方法的工作原理),然后将该对象分配给一个在语法上有效命名的新对象.

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`

这篇关于加载别人的.rdata文件,无法访问数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆