R | dplyr Variable Column Names (Indirection)
The dplyr
grammar has a handy data masking feature, which means that within dplyr
verbs, column variables in tables can be referenced like regular variables (e.g. you can do select(tbl, some_column)
instead of select(tbl, "some_column")
.
This is convenient for performing exploratory analysis with hardcoded column names, but is problematic when the code needs the column name to be a variable. The dplyr
documentation refers to this as "indirection".
See below for resources for dealing with this issue: