For all factor-variables, get the order of levels and use this as input in rpivottable.

make_sorters(df)

Arguments

df

ablanor table

Value

a text string containing a function that defines the sorters for each factor-variable. This should be given in input in the getPivotTable from shiny

Examples

df <- data.frame(kjonn = factor(x = c("M", "K", "M", "M"),
                                levels = c("M", "K"),
                                ordered = TRUE))
s <- ablanor::make_sorters(df)
s
#> [1] "function(attr) {\nvar sortAs = $.pivotUtilities.sortAs;\nif (attr == \"kjonn\") { return sortAs([\"M\" , \"K\"]); }\n}"
if (FALSE) { # \dontrun{
rpivotTable::rpivotTable(df, sorters = make_sorters(df, sorters =))
} # }