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.
Finally took the plunge and started making my first R package today. Time to round up my herd of functions. Exciting! Anyone got any advice, anything you wish you’d known before you started yours? #rstats— Adam Pegler (@pegleraj) 12 October 2018
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!Usethis, devtools, and testthat make it easy to do things right.— Mathew Ling (@lingtax) 13 October 2018
Make sure you have no variables loose in your environment.
Have fun. pic.twitter.com/7s5rNXaCTY
Brenton Wiernik also encouraged me to write tests with testthat.
Write tests with testthat early and often— Brenton Wiernik 🏳️🌈 (@bmwiernik) 13 October 2018
(4) Tony said: "for god's sake don't write the essay the night before the deadline!" Sounds really sensible.
Don't save documentation for the end.— Tony Rodriguez (@ttrodrigz) 13 October 2018
(5) Both Cedric and Danton recommended the devtools::load_all() function, Usethis, and restarting R intermittently.
devtools::load_all() is very useful when you need to test something interactively. Usethis package is a time-saver!— Cédric Batailler (@cedricbatailler) 13 October 2018
As you build functions in R/ directory, use devtools::load_all() to load into package environment and occasionally restart R to clear out existing function / objects. A big headache for me was that I’d finalize a function in R/ but it also existed in global env, which supercedes.— Danton Noriega (@dantonnoriega) 13 October 2018
(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.
Made my first package 2 weeks ago. Using the talk by @jimhester_ : https://t.co/mEdUjrxZIG Great instructions!— Eric Krantz (@EricLeeKrantz) 14 October 2018
(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:
I made my first package this week using @hadleywickham's great 'R packages' book https://t.co/atkeT6IlCm Also not sure I would have managed without #devtools and #roxygen2. Good luck!— James Grecian (@JamesGrecian) 13 October 2018
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.
No comments:
Post a Comment