Getting ready to attend rOpenSci unconf18 and probably working on tidyverse-like functions for the first time
It’s Friday 7pm and it’s been a long week with ups and downs1. But I’m enthused as I write this blog post. In less than a month from now I’ll be attending rOpenSci unconf18 and it’ll be my first time at this type of event. Yay!
Building on my streak of good news, I'm delighted to have been selected to attend @rOpenSci #Unconf18 https://t.co/Xe6lojB7TS ^_^ Also, thanks to the https://t.co/o5OwUWEaBD and @LieberInstitute for their support! I'm hoping to relay as much as I can to @LIBDrstats #rstats— 🇲🇽 Leonardo Collado-Torres (@lcolladotor) April 11, 2018
In my self introduction to everyone attending, I mentioned that I don’t use the pipe (
%>%) symbol and that I use
<- for assignment.
Recently I had my pre-unconf chat with Stefanie Butland (read more about these chats in her great blog post). In my notes to Stefanie before our chat I had mentioned again my lack of R piping experience and we talked about it. As we talked, it became clear that a blog post on related topics would be useful. Sure, I could have asked directly to the other unconf18 participants, but maybe others from the R community in general can chime in or benefit from reading the answers.
Coding style and git
I’m attending unconf18 with an open mind and I think of myself as someone who can be quite flexible (not with my body!) and accommodating. I’m assuming that most participants at unconf18 will use
= for assignment. I’m not looking to start any discussions about the different assignment operators. Simply, I am willing to use whatever the majority uses. Just like I did in my first pull request to the
blogdown package (issue 263). I was trying to follow Yihui Xie’s coding style to make his life easier and have a clean (or cleaner) git history. From Yihui’s post on this pull request I can see that he liked it.
Keeping this in mind, I think that following the coding style of others will be something I’ll do at unconf18. I haven’t really worked in any R packages with many developers actively working on the package. But I imagine that setting a common coding style will minimize git conflicts, and no one wants those2. I don’t know if we’ll all follow some common guidelines at unconf18. I actually imagine that it’ll be project-specific. Why? Well because you can create an R project in RStudio3 and set some defaults for the project such as:
- the number of spaces for tab
- line ending conversions
We can also set some global RStudio preferences like whether to auto-indent code after paste, length of lines.
Additionally, we can decide whether we’ll use the RStudio “wand” to reformat code.
Maybe all of this is unnecessary, maybe everyone will work in different non-overlapping functions and thus avoid git conflicts. For example, at my job sometimes I write code with
= users, but we don’t work on the same lines of the code file. Later on it becomes easy to identify who wrote which line without having to use
git blame (awful name, right?).
So far, I think that these coding style issues are minor and will be easily dealt with. I think that we’ll all be able to adapt and instead focus on other problems (like whatever the package is trying to solve) and enjoy the experience (network, build trust as Stefanie put it).
My second concern has to do with something I imagine could require more effort: my homework before the unconf. That is, writing tidyverse-like functions. Like I’ve said, I haven’t used the R pipe
%>% symbol. I’ve executed some code with it before, seeing it in many blog posts, but I’ve never actually written functions designed to be compatible with this type of logic.
If I help write a function that is not pipe-friendly, then it might not integrate nicely with other functions written by the rest of the team. It would lead to workarounds in the vignette or maybe having someone else re-factor my first function to make it pipe-friendly. Sure, I would learn from observing others make changes to my code. But I want to take advantage as much as I can from my experience at rOpenSci unconf4!
Since I don’t really use
%>%, I’m unfamiliar with many things related to pipe-friendly (tidyverse-like) functions. For example:
- Do you document them differently? Like make a single Rd file for multiple functions. Or do you make an Rd file per function even if the example usage doesn’t involve
- I know that the first argument is important in pipe-friendly functions. But I ignore if the second and other arguments play a role or not.
- Do people use the ellipsis (
...) argument in pipe-friendly functions? With my derfinder package I ended up a very deep rabbit hole using
.... I explained some of the logic in my
dotsblog post (there are fair criticisms to going deep with
...in the comments).
- How do you write unit tests for pipe-friendly functions? Similar to how you write documentation for them, do the unit tests just test one function a time or do they test several at a time (that is the output after using
These and other questions could involve time getting familiar with. Time that I could spend now, before unconf18, learning and at least getting a better sense of what to expect. Maybe I’m complicating myself and worrying too much about this. I imagine that the solution will involve a combination of:
- Checking some popular tidyverse packages that use
%>%. Like the vignettes/README files and examples.
- Reading more about this in a book(s): I don’t know which one though.
- Playing around a bit as a user with some of these functions. See what error messages pop up: actually I don’t know how users debug a series of functions tied together via
I’m not saying everyone should learn about these topics before unconf18. I think that we are all (well, maybe excluding some) worried about not knowing \(X\) or \(Y\)
usethis/etc topic before unconf18. And that will part of why it’ll be great to meet everyone in what is known to be an extremely welcoming R conference ^^ (seriously, check all the unconf17 posts!).
## And I'm done proofreading the post. Yay! Sys.time()
##  "2020-02-12 22:33:17 EST"
This blog post was made possible thanks to:
 C. Boettiger. knitcitations: Citations for ‘Knitr’ Markdown Files. R package version 1.0.10. 2019. URL: https://CRAN.R-project.org/package=knitcitations.
 A. Oleś, M. Morgan, and W. Huber. BiocStyle: Standard styles for vignettes and other Bioconductor documents. R package version 2.14.4. 2020. URL: https://github.com/Bioconductor/BiocStyle.
 H. Wickham, J. Hester, and W. Chang. devtools: Tools to Make Developing R Packages Easier. R package version 2.2.1. 2019. URL: https://CRAN.R-project.org/package=devtools.
 Y. Xie, A. P. Hill, and A. Thomas. blogdown: Creating Websites with R Markdown. ISBN 978-0815363729. Boca Raton, Florida: Chapman and Hall/CRC, 2017. URL: https://github.com/rstudio/blogdown.
## ─ Session info ─────────────────────────────────────────────────────────────────────────────────────────────────────── ## setting value ## version R version 3.6.2 (2019-12-12) ## os macOS Catalina 10.15.2 ## system x86_64, darwin15.6.0 ## ui X11 ## language (EN) ## collate en_US.UTF-8 ## ctype en_US.UTF-8 ## tz America/New_York ## date 2020-02-12 ## ## ─ Packages ─────────────────────────────────────────────────────────────────────────────────────────────────────────── ## package * version date lib source ## assertthat 0.2.1 2019-03-21  CRAN (R 3.6.0) ## backports 1.1.5 2019-10-02  CRAN (R 3.6.0) ## bibtex 0.4.2.2 2020-01-02  CRAN (R 3.6.0) ## BiocManager 1.30.10 2019-11-16  CRAN (R 3.6.1) ## BiocStyle * 2.14.4 2020-01-09  Bioconductor ## blogdown 0.17 2019-11-13  CRAN (R 3.6.1) ## bookdown 0.17 2020-01-11  CRAN (R 3.6.0) ## callr 3.4.1 2020-01-24  CRAN (R 3.6.2) ## cli 2.0.1 2020-01-08  CRAN (R 3.6.0) ## colorout * 1.2-1 2019-05-07  Github (jalvesaq/colorout@7ea9440) ## crayon 1.3.4 2017-09-16  CRAN (R 3.6.0) ## desc 1.2.0 2018-05-01  CRAN (R 3.6.0) ## devtools * 2.2.1 2019-09-24  CRAN (R 3.6.1) ## digest 0.6.23 2019-11-23  CRAN (R 3.6.0) ## ellipsis 0.3.0 2019-09-20  CRAN (R 3.6.0) ## evaluate 0.14 2019-05-28  CRAN (R 3.6.0) ## fansi 0.4.1 2020-01-08  CRAN (R 3.6.0) ## fs 1.3.1 2019-05-06  CRAN (R 3.6.0) ## glue 1.3.1 2019-03-12  CRAN (R 3.6.0) ## htmltools 0.4.0 2019-10-04  CRAN (R 3.6.0) ## httr 1.4.1 2019-08-05  CRAN (R 3.6.0) ## jsonlite 1.6 2018-12-07  CRAN (R 3.6.0) ## knitcitations * 1.0.10 2019-09-15  CRAN (R 3.6.0) ## knitr 1.27 2020-01-16  CRAN (R 3.6.0) ## lubridate 1.7.4 2018-04-11  CRAN (R 3.6.0) ## magrittr 1.5 2014-11-22  CRAN (R 3.6.0) ## memoise 1.1.0 2017-04-21  CRAN (R 3.6.0) ## pkgbuild 1.0.6 2019-10-09  CRAN (R 3.6.0) ## pkgload 1.0.2 2018-10-29  CRAN (R 3.6.0) ## plyr 1.8.5 2019-12-10  CRAN (R 3.6.0) ## prettyunits 1.1.1 2020-01-24  CRAN (R 3.6.2) ## processx 3.4.1 2019-07-18  CRAN (R 3.6.0) ## ps 1.3.0 2018-12-21  CRAN (R 3.6.0) ## R6 2.4.1 2019-11-12  CRAN (R 3.6.1) ## Rcpp 1.0.3 2019-11-08  CRAN (R 3.6.0) ## RefManageR 1.2.12 2019-04-03  CRAN (R 3.6.0) ## remotes 2.1.0 2019-06-24  CRAN (R 3.6.0) ## rlang 0.4.3 2020-01-24  CRAN (R 3.6.2) ## rmarkdown 2.1 2020-01-20  CRAN (R 3.6.0) ## rprojroot 1.3-2 2018-01-03  CRAN (R 3.6.0) ## sessioninfo 1.1.1 2018-11-05  CRAN (R 3.6.0) ## stringi 1.4.5 2020-01-11  CRAN (R 3.6.0) ## stringr 1.4.0 2019-02-10  CRAN (R 3.6.0) ## testthat 2.3.1 2019-12-01  CRAN (R 3.6.0) ## usethis * 1.5.1 2019-07-04  CRAN (R 3.6.0) ## withr 2.1.2 2018-03-15  CRAN (R 3.6.0) ## xfun 0.12 2020-01-13  CRAN (R 3.6.0) ## xml2 1.2.2 2019-08-09  CRAN (R 3.6.0) ## yaml 2.2.0 2018-07-25  CRAN (R 3.6.0) ## ##  /Library/Frameworks/R.framework/Versions/3.6/Resources/library
Feeling welcomed can be hard… oh well.↩︎
We could talk about git for a long time too. But I hope that I’ll get by with some git push, git pull, and maybe git branch.↩︎
It’s one of the sponsors http://unconf18.ropensci.org/#sponsors and well, probably want most will be using since it has such nice tools for writing R packages.↩︎
Specially since most only attend one unconf, I think. So it’s different from other conferences that you can experience multiple years and network with the group across a longer period of time: that’s what I’ve done with the Bioconductor meetings.↩︎