What are some good practices for programming in R
?
Since R
is a special-purpose language that I don't use all the time, I typically just hack together some quick scripts that do what I need.
But what are some tips for writing clean and efficient R
code?
1) RStudio Most R users have probably heard of RStudio. It's by far one of the most popular R tools in existence and you probably already have it.
You already provide some hints by stating your approach is 'hack quick scripts'. If you want best practices and structure, simple follow the established best practices from CRAN:
R CMD check
which is very useful\examples{}
section of the documentation as this will be running during R CMD check
and provides an easy entry to regression testingI recommend Josh Reich's Load, Clean, Func, Do workflow from this previous question.
In addition I recommend following coding guidelines such as Google's R Style Guide. Using a coding style guide makes reading the code later so much easier.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With