Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Undo command in R

Tags:

r

I can't find something to the effect of an undo command in R (neither on An Introduction to R nor in R in a Nutshell). I am particularly interested in undoing/deleting when dealing with interactive graphs.

What approaches do you suggest?

like image 686
Roberto Avatar asked Jun 19 '10 17:06

Roberto


People also ask

Is there an undo in RStudio?

Unless you still have the file open in the editor, no, there's no way to undo the change. But since you mention RStudio in the title, I'm assuming that you're editing the file from within the RStudio text editor? In that case, no problem — just hit “undo”.

How do I delete old commands in R?

Simply hit Ctrl+L on the keyboard and you will see that everything written in the console will be erased and the console will be cleared.

Which command is used to undo the previous steps?

To undo an action press Ctrl+Z. If you prefer your mouse, click Undo on the Quick Access Toolbar. You can press Undo (or CTRL+Z) repeatedly if you want to undo multiple steps.


1 Answers

You should consider a different approach which leads to reproducible work:

  • Pick an editor you like and which has R support
  • Write your code in 'snippets', ie short files for functions, and then use the facilities of the editor / R integration to send the code to the R interpreter
  • If you make a mistake, re-edit your snippet and run it again
  • You will always have a log of what you did

All this works tremendously well in ESS which is why many experienced R users like this environment. But editors are a subjective and personal choice; other people like Eclipse with StatET better. There are other solutions for Mac OS X and Windows too, and all this has been discussed countless times before here on SO and on other places like the R lists.

like image 155
Dirk Eddelbuettel Avatar answered Nov 11 '22 22:11

Dirk Eddelbuettel