Description Usage Arguments Details Value See Also Examples
Tabulate and visualize conjoint features, and their display frequencies and proportions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | cj_freqs(
data,
formula,
id = NULL,
weights = NULL,
feature_order = NULL,
feature_labels = NULL,
level_order = c("ascending", "descending"),
...
)
cj_props(data, formula, id, weights = NULL, margin = NULL, ...)
cj_table(
data,
formula,
feature_order = NULL,
feature_labels = NULL,
level_order = c("ascending", "descending"),
include_reference = FALSE,
...
)
|
data |
A data frame containing variables specified in |
formula |
An RHS formula specifying conjoint features to tabulate. All RHS variables should be factors; all levels across features should be unique. |
id |
An RHS formula specifying a variable holding respondent identifiers, to be used for clustering standard errors. By default, data are unclustered. |
weights |
An (optional) RHS formula specifying a variable holding survey weights. |
feature_order |
An (optional) character vector specifying the names of feature (RHS) variables in the order they should be encoded in the resulting data frame. |
feature_labels |
A named list of “fancy” feature labels to be used in output. By default, the function looks for a “label” attribute on each variable in |
level_order |
A character string specifying levels (within each feature) should be ordered increasing or decreasing in the final output. This is mostly only consequential for plotting via |
... |
Ignored. |
margin |
A numeric value passed to |
include_reference |
A logical indicating whether to include a “reference” column that indicates whether a feature level is the reference category for that feature. Default is |
These functions provide related but slightly different functionality. cj_table
simply creates a data frame of features and their levels, which is useful for printing. cj_props
provides tidy proportion tables to examine cross-feature restrictions in conjoint designs that are not equally randomized. This enables, for example, tabulation and visualization of complete restrictions (where combinations of two or more features are not permitted), as well as calculation of AMCEs for constrained designs appropriately weighted by the display proportions for particular combinations of features.
cj_freqs
provides marginal display frequencies, which are a descriptive check on the presentation of individual conjoint features (for example, to ensure equal or intentionally unequal appearance of levels). This is mostly useful for plotting functionality provided in plot.cj_freqs
, which provides barcharts for the frequency with which each level of each feature was presented.
A data frame of class “cj_freqs”, “cj_props”, etc.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | data(immigration)
# identify all levels
cj_table(immigration, ~ Gender + Education + LanguageSkills)
cj_table(immigration, ~ Gender + Education + LanguageSkills, include_ref = TRUE)
# display frequencies
(f <- cj_freqs(immigration, ~ Gender + Education + LanguageSkills, id = ~ CaseID))
# restrictions
## check display proportions
cj_props(immigration, ~ Job, id = ~ CaseID)
## check which combinations were not allowed
subset(cj_props(immigration, ~ Job + Education, id = ~ CaseID), Proportion == 0)
# plotting
(p <- plot(f))
## change ggplot2 theme
p + ggplot2::theme_bw()
## monochrome bars
p + ggplot2::scale_fill_manual(values = rep("black", 9)) +
ggplot2::theme(legend.position = "none")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.