简体   繁体   English

如何从RData查看原始脚本或函数?

[英]How to see original script or function from RData?

I created a very small script (without saving) in RCmdr top window, but I only saved the workspace. 我在RCmdr顶部窗口中创建了一个非常小的脚本(不保存),但仅保存了工作区。

When I reload this I can't see anything that was in the top window originally. 重新加载时,我看不到最初在顶部窗口中的任何内容。 My mistake I know, but is there a way to see any hint of the functions etc I may have called, from the workspace file? 我知道我的错误,但是有没有办法从工作区文件中看到我可能已经调用的函数的任何提示? I can see the objects - but not what created them. 我可以看到这些对象-但看不到是什么创建它们的。

If you open a new R session, try hitting the up-arrow keys. 如果您打开一个新的R会话,请尝试按向上箭头键。 The normally invisible .Rhistory file is usually loaded at the start of a new session if the prior session ended normally. 如果先前的会话正常结束,则通常在新会话开始时加载通常不可见的.Rhistory文件。 If the session is open in a GUI hten you may be able to display the list of commands with a menu command. 如果会话在GUI中打开,则可以使用菜单命令显示命令列表。 This may also display that file: 这可能还会显示该文件:

loadhistory(file = ".Rhistory")

The history is cumulative, so unless you had a really long session intervening you may still be able to get code going back for several session. 历史记录是累积的,因此除非您进行了很长的会话干预,否则您仍然可以使代码返回几个会话。 I think it keeps the last 500 entries by default. 我认为它默认保留最近的500个条目。 Actually turns out to be 512. See: 实际上是512。请参阅:

?history

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM