jessica
jessica

Reputation: 1355

R Studio/R Accessing Blocks of Previously Run Code

Is there a way to display past commands in R/R Studio?? I know in R Studio there is a shortcut (CTRL+UP Arrow) that allows you to see past lines you have ran. But this shortcut only allows you to access only a single line, not a block of previously run code. Is there a package, or some way in R to display and select blocks of past code in R/R Studio?

Upvotes: 1

Views: 1199

Answers (1)

Ricardo Oliveros-Ramos
Ricardo Oliveros-Ramos

Reputation: 4349

Here you can find a description of the panes in R Studio, including the "history" pane. There you can select several lines and paste them into the code.

Also, you can use the command savehistory() to save your history in a file you can the modify. If you want to choose the name of the file to be saved, use

savehistory(file = filename)

The same option is available in the basic R GUI (MS Windows), with "Save history" in the "File" menu (as a .RHistory file). Then, you can open it with any text editor and modify your history to make a script.

To see a specific number of lines, you can use history(25) (for 25 previous lines).

Upvotes: 1

Related Questions