n_prefix {tidybayes} | R Documentation |
Prefix function generator for composing dimension index columns
Description
Generates a function for generating names of index columns for factors in
compose_data()
by prefixing a character vector to the original
column name.
Usage
n_prefix(prefix)
Arguments
prefix |
Character vector to be prepended to column names by
Returns a function. The function returned takes a character vector,
|
See Also
The .n_name
argument of compose_data()
.
Examples
library(magrittr)
df = data.frame(
plot = factor(paste0("p", rep(1:8, times = 2))),
site = factor(paste0("s", rep(1:4, each = 2, times = 2)))
)
# without changing `.n_name`, compose_data() will prefix indices
# with "n" by default
df %>%
compose_data()
# you can use n_prefix() to define a different prefix (e.g. "N"):
df %>%
compose_data(.n_name = n_prefix("N"))