The correct answer to any question is always “it depends”, e.g., “Should I use tidyverse or base R?” I just saw Karl Broman described himself as a somewhat desiccated baseR-er. I have to admit that most of time I use base R, too. Why? I rarely do data analysis. My primary job is programming, and frankly, I consider my programming skills to be mediocre.1 I’m not good at learning new things. Unfortunately, I learned R the “wrong” way, and became a master of
par() like Karl more than a decade ago when ggplot2 was not born yet.
If I were to learn R again to do data analysis, I’d very much like to follow David Robinson’s suggestions. For now, I’d say I’m completely comfortable with the old-fashioned
lapply() for my programming needs, especially when developing R packages. Perhaps it is only me, but I find the pipe operator
%>% obfuscatory when used for programming and also a hassle to debug. The first time I saw it being used in a package was in leaflet two years ago, and I stared at the chain for quite a while trying to parse it in my brain.2 For the pipe in *nix commands, I absolutely love it. For
%>% in R, I guess I won’t use it until someday when I mostly work on data analysis.
This post is not meant to defend base R. Life is short, and base R is big. There are certainly good and bad things about base R. My one and only complaint about base R is partial matching (especially for list elements). Other than that, I’m totally fine with it, even with all its known drawbacks. Again, I’m a programmer. Also remember the sample size is one (perhaps two, counting Karl), so please do not draw any conclusions from this short post. That said, if you are a beginner in R and I must offer a suggestion, I’d suggest tidyverse anyway (with a reservation on
%>% unless your job is data analysis), because it is not worth the time learning all the inconsistencies in base R.
- This is not a representative example of pipes, though, since each function returns a function, and I had a hard time figuring out what
safePaletteFunc(pal)(x)would do and the order in which these functions would be applied to