有没有办法将最后执行的命令打印为 R 中的文本字符串?我试过history(1)
了,但在 RStudio 中,这只是将焦点更改为“历史”窗格。我试过print(history(1))
和 `cat(history(1))',两者都没有返回。这是我在尝试这些命令时在控制台中得到的:
> history(1)
> history(1)[1]
NULL
> cat(history(1))
> print(history(1))
NULL
我希望避免这里savehistory('file'); myhistory <- scan('file','character')
提出的解决方案。