prep_df.Rd
Prepares a dataframe based on provided filters and naming options
List of filters to be applied on the dataframe.
List of values used for naming.
Dataframe to be processed.
Variable used for coloring.
Facet grid side ("left" by default).
Variable used for facet grid ("VIS_Groep" by default).
Variable used for facet grid naming ("VIS_Groep_naam" by default).
A prepared dataframe with applied filters and new columns.
This function collapses values from the naming list into a single string, removes null elements from the filter list, transforms filter list into elements suitable for filtering, applies filters, adds new columns, and casts var used as color to factor.
df <- dplyr::tibble(
VIS_Groep = sample(c("Group1", "Group2", "Group3"), 100, replace = TRUE),
VIS_Groep_naam = sample(c("Name1", "Name2", "Name3"), 100, replace = TRUE),
var1 = sample(c("A", "B", "C"), 100, replace = TRUE),
var2 = rnorm(100),
color_var = sample(c("Red", "Blue", "Green"), 100, replace = TRUE)
)
lFilters <- list("A;var1")
lValues_for_naming = list("Name1;VIS_Groep_naam", "Name2;VIS_Groep_naam")
color_var = "color_var"
dfPrepared <- prep_df(lFilters, lValues_for_naming, df, color_var, facet = "right")