I have long wanted to write R packages. But for some reason, I thought that I wasn’t capable of such a feat. “R package authors are super stars, I’m just me,” I would think in a mix of despair and admiration, marveling at some new and useful R package, and wishing I could create such functional beauty.
But now the day I have long dreamed of has arrived! I have authored an R package, and it is perhaps the most satisfying feeling I have ever had using R. Trust that I have had many R-related feelings, so I do not make this statement lightly. On top of now holding myself in higher regard, I am also wondering what the heck took me so long?
It turns out that if you have code for your function(s) ready, and you have RStudio, you are already about 90% of the way to authoring your very own R package. Besides writing the code, there is a small bit about downloading some packages that let you develop your package and help you create the needed documentation (devtools and roxygen2), and then a little messing around. It really only took me a few minutes to watch this video and then I was set.
My first package I wrote has to do with social network interventions (I will share the details on this at a later time), and it is working just as I would have hoped. My next step is to actually submit the package to CRAN (the comprehensive R archive network) at this website. I’m holding out on that step with this package since it is related to a paper that I am in the process of writing, and I want to wait until the paper is accepted.
Now that I have written my first package, my mind is reeling with all the possibilities. Hurrah for R packages!