RMHogervorst / cleancode

simple blog about cleaner code and starting with R
https://rmhogervorst.github.io/cleancode/
MIT License
0 stars 0 forks source link

example put all your favorite functions in 1 package, w/ documentation #21

Open RMHogervorst opened 8 years ago

RMHogervorst commented 7 years ago

WHEN DO YOU TRANSITION TO A PACKAGE?

As soon as you use something in multiple projects. JT leek says "As soon as you have 2 functions. Why 2? After you have more than one function it starts to get easy to lose track of what your functions do, it starts to be tempting to name your functions foo or tempfunction or some other such nonsense. "

progression:

  1. I do a set of actions often
  2. automate that to a function
  3. you have a set of functions that you often use and put them together in a script
  4. You have a set of scripts that you often use.

If you are in situation 3 or 4, you might consider creating a package.

  1. it's fun!
  2. you don't have to remember where you put the scripts you can just load the package and all the functions are available.
  3. way more easy to share.

resources:

  1. Hillary Parker's^1 simple instructions on how to make a package from scratch https://hilaryparker.com/2014/04/29/writing-an-r-package-from-scratch/
  2. hadley Wickham's book about packages http://r-pkgs.had.co.nz/
  3. Karl Broman's tutorial http://kbroman.org/pkg_primer/
  4. This is a combination of all the above sources: http://tinyheero.github.io/jekyll/update/2015/07/26/making-your-first-R-package.html
  5. Rstudio's tutorial https://support.rstudio.com/hc/en-us/articles/200486488-Developing-Packages-with-RStudio

[1]: Hillary https://hilaryparker.com/ works at stitchfix and has a podcast with Roger Peng from the Johns Hopkins University

RMHogervorst commented 7 years ago

There are so many resources out there for writing r-packages that you probably don't need another one. ( I will list them in this post) But when do you transition to a package? will be the focus of this short post