From fb5ae27461b909a8a4da1475b2bc588fd1b06dd8 Mon Sep 17 00:00:00 2001 From: Brandon Bertelsen Date: Wed, 13 May 2020 00:51:34 -0500 Subject: [PATCH] Updating FAQ with sorting examples --- vignettes/FAQ.Rmd | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/vignettes/FAQ.Rmd b/vignettes/FAQ.Rmd index 22a6e6b9..f5a7afac 100644 --- a/vignettes/FAQ.Rmd +++ b/vignettes/FAQ.Rmd @@ -200,6 +200,31 @@ myTheme <- themeNew( writeExcel(ct_summary, filename = "output", theme = myTheme) ``` +### How do I sort a categorical or multiple response question's presenation? + +You can sort response categories alphabetically or by proportion. You can apply a fixed presentation order and you can pin response categories to the top or bottom. + +```{r, eval = FALSE} +ds = loadDataset("Example dataset") +# Use ds = newExampleDataset() if it doesn't work +ct = crosstabs(ds) +ct = sortAliases(ct) + +writeLatex(ct, ...) +``` + +The default behaviour sorts all questions that can be sorted, descending by order of proportion. But we can apply a variety of different sorting options by using the `sortAliases` function repeatedly. + +```{r, eval = FALSE} +# load ds, define theme ... + +ct = sortAliases(ct, var = c("a", "b"), alpha = TRUE) # sort a/b by alpha +ct = sortAliases(ct, var = "c") # sort c by numeric +ct = sortAliases(ct, var = "d", pin_to_bottom = "Don't know") + +writeLatex(ct, ...) +``` + ### How do I request a new feature? We welcome features requests as new issues to the [crunchtabs github repository](https://github.com/Crunch-io/crunchtabs/issues)