Put detailed index summaries to a model rack
Source:R/make_indices_detailed.R
rack_put_indices_detailed.RdGiven a model rack, calculate detailed index summaries and put
them to a separate column. If index summaries for a subset of columns
already exist, new summaries will be appended to the existing. It is
possible to put new summaries to a separate rack column by changing id
parameter.
Usage
rack_put_indices_detailed(
rack,
data = "data$x",
cols = everything(),
na.rm = FALSE,
id = NULL
)Arguments
- rack
A model rack.
- data
One of the following:
"data$x" to use model features for indices
A name of a column containing dataframe to use its columns for indices
a dataframe to take index columns from
- cols
A tidyselect expression to subset columns from data. By default is
everything()so all columns are taken.- na.rm
Drop NA categories before calculating percentages? Default is FALSE.
- id
Sub-name of a column to put index summaries to. By default it's
NULLand index summaries will be put to column named "indices_detailed". If e.g. you want to put indices to "indices_detailed_demo", you can setidto "demo".
Examples
library(dplyr)
rack_extended <-
example_seg_rack %>%
# put demo data to "demo" column
rowwise() %>%
mutate(demo = list(example_demo_data[1:100,])) %>%
ungroup() %>%
rack_put_indices_detailed(
data = "demo",
cols = everything(),
id = "demo"
)
#> ! Found 2 columns with missing or invalid labels: "weight" and "segment".
#> ℹ Replacing these labels with {.code NA_character_}
#> ! Found 2 columns with missing or invalid labels: "weight" and "segment".
#> ℹ Replacing these labels with {.code NA_character_}
#> ! Found 2 columns with missing or invalid labels: "weight" and "segment".
#> ℹ Replacing these labels with {.code NA_character_}