cross2_var_vectors {CGPfunctions}R Documentation

Cross two vectors of variable names from a dataframe

Description

Cross two vectors of variable names from a dataframe

Usage

cross2_var_vectors(data, x, y, verbose = FALSE)

Arguments

data

the dataframe or tibble the variables are contained in.

x, y

These are either character or integer vectors containing the names, e.g. "am" or the column numbers e.g. 9

verbose

the default is FALSE, setting to TRUE will cat additional output to the screen

Value

a list with two sublists 'lista' and 'listb'. Very handy for feeding the lists to 'purrr' for further processing.

Author(s)

Chuck Powell

Examples

cross2_var_vectors(mtcars, 9, c(2, 10:11))
cross2_var_vectors(mtcars, "am", c("cyl", "gear", "carb"))
x2 <- c("am", "carb")
y2 <- c("vs", "cyl", "gear")
cross2_var_vectors(mtcars, x2, y2, verbose = TRUE)

## Not run: 
variables_list <- cross2_var_vectors(mtcars, x2, y2)
mytitles <- stringr::str_c(
  stringr::str_to_title(variables_list$listb),
  " by ",
  stringr::str_to_title(variables_list$lista),
  " in mtcars data"
  )
purrr::pmap(
.l = list(
   x = variables_list[[1]], # variables_list$lista
   y = variables_list[[2]], # variables_list$listb
   title = mytitles
),
.f = CGPfunctions::PlotXTabs2,
data = mtcars,
ylab = NULL,
perc.k = 1,
palette = "Set2"
)


## End(Not run)


[Package CGPfunctions version 0.6.3 Index]