View source: R/plot_projoint_choice_level_mm.R
| plot_projoint_choice_level_mm | R Documentation |
Internal helper used by plot.projoint_results to render
choice-level marginal means (MMs). Supports a bar chart or a horizontal
pointrange layout and optional custom level labels.
plot_projoint_choice_level_mm(
x,
.type = "pointrange",
.estimates = "corrected",
.labels = NULL,
.show_attribute = TRUE,
.remove_xaxis = FALSE,
.xlim = c(0, 1),
.plot.margin = c(top = 1, left = 2, bottom = 1, right = 2),
...
)
x |
A |
.type |
Character. Either |
.estimates |
Character. Which estimate version to plot:
|
.labels |
Optional character vector of length 2 for custom level labels
(left/right). If |
.show_attribute |
Logical; if |
.remove_xaxis |
Logical; if |
.xlim |
Numeric length-2 giving the x-axis limits. Default |
.plot.margin |
Numeric vector of plot margins in cm,
|
... |
Currently unused (reserved for future extensions). |
This helper expects that the projoint_results object already
contains a single pair of choice-level MMs (i.e., one att_level_choose
and one att_level_notchoose). It is called internally by
plot.projoint_results when x$structure == "choice_level"
and x$estimand == "mm".
When .type = "pointrange", the level labels are placed just outside
.xlim to avoid overlap with the confidence interval. If the two levels
correspond to different attributes, the attribute title is omitted and a
message is emitted.
A ggplot2 object.
plot.projoint_results for the user-facing plot method.
data(exampleData1)
dat <- reshape_projoint(exampleData1,
.outcomes = c("choice1", "choice2", "choice1_repeated_flipped")
)
att <- unique(dat$labels$attribute_id)[1]
levs <- subset(dat$labels, attribute_id == att)$level_id
lev_names <- sub(".*:", "", levs)
q <- set_qoi("choice_level", "mm",
.att_choose = att, .lev_choose = lev_names[2],
.att_notchoose = att, .lev_notchoose = lev_names[1]
)
fit <- projoint(dat, .qoi = q)
plot(fit)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.