I use git as a version control system in RStudio. I have several different versions of the R script stored in git. Suppose I deleted a block of code, but now I decided that I want to paste the code into the current R script again. I know that the code includes the ddply function. This is my current workflow:
I open a terminal in RStudio and type:
git grep ddply $(git rev-list --all)
This causes hundreds of lines of code, for example:
2c975e1faee880545546646648f5be2b55f60fc757c29828f1f:reports/:data <- ddply(x, .(as.factor(y), summarise, mean(count)) 2c975e1faee880545546646648f5be2b55f60fc757c29828f1f:reports/:data <- ddply(x, .(as.factor(y), summarise, mean(count)) 2c975e1faee880545546646648f5be2b55f60fc757c29828f1f:reports/:data <- ddply(x, .(as.factor(y), summarise, mean(count)) 2c975e1faee880545546646648f5be2b55f60fc757c29828f1f:reports/:data <- ddply(x, .(as.factor(y), summarise, mean(count)) 2c975e1faee880545546646648f5be2b55f60fc757c29828f1f:reports/:data <- ddply(x, .(as.factor(y), summarise, mean(count))
Sifting through the code and finally finding the bit I was looking for. I copy the corresponding bit of code from the terminal and paste it back into my R script. Before using the code, I need to remove this bit: 2c975e1faee880545546646648f5be2b55f60fc757c29828f1f:reports/:
Right now this seems like a rather slow and awkward way to reuse old versioned code, and I might be better off using Rhistory.
Is there a faster way to get version-driven code from git and back to an R script in RStudio?
luciano
source share