cross2_var_vectors: Cross two vectors of variable names from a dataframe

Description Usage Arguments Value Author(s) Examples

View source: R/cross2_var_vectors.R

Description

Cross two vectors of variable names from a dataframe

Usage

1
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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)

CGPfunctions documentation built on Nov. 12, 2020, 5:08 p.m.