Is there a way to print the last executed command from as a text string in R? I've tried history(1)
, but in RStudio this just changes the focus to the the "History" pane. I've tried print(history(1))
and `cat(history(1))', both of which return nothing. Here is what I get in the console when I try these commands:
> history(1)
> history(1)[1]
NULL
> cat(history(1))
> print(history(1))
NULL
I'm hoping to avoid the savehistory('file'); myhistory <- scan('file','character')
solution proposed here.