Prefix function generator for composing dimension index columns
Generates a function for generating names of index columns for factors in
compose_data()
by prefixing a character vector to the original
column name.
n_prefix(prefix)
prefix |
Character vector to be prepended to column names by
Returns a function. The function returned takes a character vector,
|
The .n_name
argument of compose_data()
.
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"))
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.