Tuesday 6 November 2018

I'm making an R package

I've got a rabble of functions that help me explore, analyse and quality assure the data I work with. My R skills are getting there. Sure there's room for (lots of) improvement, but all of my latest scripts are sufficiently less cringeworthy than my early attempts. I'm remembering to add na.rm = TRUE. 90% of the time, anyway. It's a perfect storm.

I'm making an R package? You know what, I think I am.


It's a (genuinely) exciting moment for me, but I thought I'd ask the good people of twitter if they had any advice before I really got going.



Here's the advice I was given by those who know a thing or two.

(1) Maelle Salmon linked me to her excellent blogpost. She argues that, from the outset, an R package has to be potentially useful to others and novel. Oh, and make sure there isn't a similar one that already does the things your going to spend hours programming. If it isn't, and there is, don't bother. Sage advice in the "if ain't broke, don't fix it" mold.


(2) Daniel Lakens recommended this primer written by Karl Broman. Among other things, Karl reminds us that you needn't distribute a package to anyone; you're likely to benefit from bundling your functions even if the package never hits CRAN. Karl talks us through the whole process: building it, documenting it, testing it, choosing a software licence, and getting it on CRAN (if it gets that far).


(3) Matthew told me to

I like the last bit. Thanks, Mathew, I will!

Brenton Wiernik also encouraged me to write tests with testthat.


(4)  Tony said: "for god's sake don't write the essay the night before the deadline!" Sounds really sensible.



(5) Both Cedric and Danton recommended the devtools::load_all() function, Usethis, and restarting R intermittently. 




(6) Eric recommended this video with a short and snappy title: "you can make a package in 20 minutes". Sounds like rubbish to me - Jim! Appreciate the positive attitude, nonetheless.

(7) And, last but by no means least, James gave a thumbs up to Hadley Wickham's book and an honorable mention to devtools and roxygen2:


So, to conclude, yes I am making an R package.

And I'll be taking the advice of the good people of twitter.

Many thanks to the people who responded to my tweet.