Eric Fail
Eric Fail

Reputation: 7948

what is the correct way to reference variables when using tidyverse with other functions?

say I would like to use with ,

I first make sure the packages are loaded,

#install.packages("tidyverse", "reporttools")  #Use this to install it, do this only once
library(reporttools); library(tidyverse) 

Second I test it with a basic tableNominal, i.e.,

data(CO2)
## the basic function
reporttools::tableNominal(vars = CO2[, 1:2], group = CO2[, "Treatment"])

That works.

Now, what is the correct way/best way to reference variables if I wish to use to subset and select before using ? Would be neat if I could use 's select helpers, e.g. contains(), one_of()

CO2 %>% select(Plant, Type, Treatment) %>% 
     reporttools::tableNominal(vars = vars(Plant, Type), group =  vars(Treatment))

Upvotes: 1

Views: 133

Answers (0)

Related Questions