Posts Tagged ‘ R tips ’

R Tip: Make Arguments Explicit in magrittr/dplyr Pipelines

March 1, 2018
By

I think this is the R Tip that is going to be the most controversial yet. Its potential pitfalls include: it is a style prescription (which makes it different than and less immediately useful than something of the nature of R Tip: Force Named Arguments), and it is heterodox (this is not how magrittr/dplyr is … Continue reading R Tip: Make Arguments Explicit in magrittr/dplyr Pipelines

Read more »

R Tip: Force Named Arguments

February 22, 2018
By

R tip: force the use of named arguments when designing function signatures. R’s named function argument binding is a great aid in writing correct programs. It is a good idea, if practical, to force optional arguments to only be usable by name. To do this declare the additional arguments after “...” and enforce that none … Continue reading R Tip: Force Named Arguments

Read more »

R Tip: Use [[ ]] Wherever You Can

February 21, 2018
By

R tip: use [[ ]] wherever you can. In R the [[ ]] is the operator that (when supplied a simple scalar argument) pulls a single element out of lists (and the [ ] operator pulls out sub-lists). For vectors [[ ]] and [ ] appear to be synonyms (modulo the issue of names). However, … Continue reading R Tip: Use [[ ]] Wherever You Can

Read more »

R Tip: Use qc() For Fast Legible Quoting

February 17, 2018
By

Here is an R tip. Need to quote a lot of names at once? Use qc(). This is particularly useful in selecting columns from data.frames: library("wrapr") # get qc() definition head(mtcars[, qc(mpg, cyl, wt)]) # mpg cyl wt # Mazda RX4 21.0 6 2.620 # Mazda RX4 Wag 21.0 6 2.875 # Datsun 710 22.8 … Continue reading R Tip: Use qc() For Fast Legible Quoting

Read more »


Subscribe

Email:

  Subscribe