从 R 中加载 .rda 文件获取数据帧的名称
我正在尝试在 r 中加载一个 .rda 文件,它是保存的数据帧。但我不记得它的名字了。
我已经尝试过
a<-load("al.rda")
,然后不允许我对 a 做任何事情。我收到错误
Error:object 'a' not found
我也尝试使用 = 符号。
如何加载此 .rda 文件以便使用它?
我用 load("al.rda) 重新启动 R,我知道出现以下错误
Error: C stack usage is too close to the limit
I am trying to load an .rda file in r which was a saved dataframe. I do not remember the name of it though.
I have tried
a<-load("al.rda")
which then does not let me do anything with a. I get the error
Error:object 'a' not found
I have also tried to use the = sign.
How do I load this .rda file so I can use it?
I restared R with load("al.rda) and I know get the following error
Error: C stack usage is too close to the limit
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我有一个类似的问题,并且无需重新安装 R 即可解决。例如,执行
load("al.rda)
工作正常,但是如果您这样做a <- load("al.rda")
将不起作用。I had a similar issue, and it was solved without reinstall R. for example doing
load("al.rda)
works fine, however if you doa <- load("al.rda")
will not work.使用“attach”,然后使用带有名称参数的“ls”。类似于:
数据文件现在很可能位于您的搜索路径上的位置 2。做:
为了开悟。现在,输入保存在 al.rda 中的任何对象的名称都可以得到它,除非您在搜索路径位置 1 中有某些内容,但 R 可能会警告您一些关于某个事物掩盖了另一个事物(如果有)的消息。
但我现在怀疑您在 RData 文件中没有保存任何内容。有两个原因:
我可以复制这种情况。如果您执行 save(file="foo.RData") 那么您将得到一个空的 RData 文件 - 您可能想要做的是 save.image(file="foo.RData") ,它保存所有对象。
你的这个.rda 文件有多大?如果它小于 100 字节(我的空 RData 文件有 42 字节长),那么我怀疑这就是发生的情况。
Use 'attach' and then 'ls' with a name argument. Something like:
The data file is now on your search path in position 2, most likely. Do:
for enlightenment. Typing the name of any object saved in al.rda will now get it, unless you have something in search path position 1, but R will probably warn you with some message about a thing masking another thing if there is.
However I now suspect you've saved nothing in your RData file. Two reasons:
I can duplicate this situation. If you do save(file="foo.RData") then you'll get an empty RData file - what you probably meant to do was save.image(file="foo.RData") which saves all your objects.
How big is this .rda file of yours? If its under 100 bytes (my empty RData files are 42 bytes long) then I suspect that's what's happened.
我不得不重新安装 R...不知何故它已损坏。我期望的简单命令
终于起作用了。
I had to reinstall R...somehow it was corrupt. The simple command which I expected of
finally worked.
load
函数确实返回它加载的变量列表。我怀疑您在加载“al.rda”时实际上遇到了错误。加载时 R 到底输出什么?它应该如何工作的示例:
为了确保这一点,请检查您实际调用的
load
函数是否是原始函数:编辑因为您现在加载文件时出现错误,它可能在某种程度上已损坏。尝试一下并说出它打印的内容:
如果无法访问该文件,则很难进行更多调查...也许您可以以某种方式共享该文件(http://www.filedropper.com 或类似的)?
The
load
function does return the list of variables that it loaded. I suspect you actually get an error when you load "al.rda". What exactly does R output when you load?Example of how it should work:
Just to be sure, check that the
load
function you actually call is the original one:EDIT Since you now get an error when you load the file, it is probably corrupt in some way. Try this and say what it prints:
Without having access to the file, it's hard to investigate more... Maybe you could share the file somehow (http://www.filedropper.com or similar)?
我通常使用 save 仅保存单个对象,然后使用以下实用程序方法使用 load 将该对象检索到给定变量名中,但检索到临时命名空间中以避免覆盖现有对象。也许它对其他人也有帮助:
该方法当然可以扩展为也返回命名对象和对象列表,但这个简单的版本对我来说是最有用的。
I usually use save to save only a single object, and I then use the following utility method to retrieve that object into a given variable name using load, but into a temporary namespace to avoid overwriting existing objects. Maybe it will be helpful for others as well:
The method can of course be extended to also return named objects and lists of objects, but this simple version is for me the most useful.