I am doing some analysis in Rstudio and at the moment – as I am refreshing my knowledge of R after a few decades away from S – this involves writing lots of one-liner statements which operate on test datasets, and then inspecting/testing the output, then finally scaling it up when I’ve checked all the little bits work.
So my history is full of syntax errors and similar. But I am making progress every time I work, and each time I work there are statements that worked, that I want to save, in order to document the bits of the session that are worth saving. Is there any established way of extracting these from my history for re-use, in RStudio? Should I just scroll through after each session and copy and paste them into a textfile with a word processor? Or is there something more clever than that that I can do, staying within RStudio?
In the history panel in RStudio (top right panel), you can click “send to source” and it will copy the line you have selected over to whatever .R file you have open in the top left panel.