Skip to contents

This function generates a histogram plot of respondent ideal points, optionally grouped or faceted by variables.

Usage

plot_resphist(
  result,
  groupVar = NULL,
  facetVar = NULL,
  addStim = FALSE,
  scaleDensity = TRUE,
  weights = c("all", "positive", "negative"),
  xlab = NULL,
  main = NULL,
  ylab = NULL,
  whichRes = NULL,
  dim = NULL,
  ...
)

Arguments

result

An object of class "aldmck" or "blackbox" containing respondent data.

groupVar

Optional grouping variable.

facetVar

Optional faceting variable.

addStim

Logical, whether to add stimuli points to the plot.

scaleDensity

Logical, whether to scale the density by group proportions.

weights

Character, specifying which weights to use ("all", "positive", "negative").

xlab

Character, label for the x-axis.

main

Character, main title for the plot.

ylab

Character, label for the y-axis.

whichRes

Optional, which respondent data to use.

dim

Optional, dimension for "blackbox" objects.

...

Additional arguments passed to ggplot2 functions.

Value

A ggplot2 object

Examples

if (FALSE) { # \dontrun{
data(result.france)
plot_resphist(result.france, addStim = TRUE, xlab = "Left-Right") +
  theme(legend.position = "bottom", aspect.ratio = 1) +
  guides(shape = guide_legend(override.aes = list(size = 4), nrow = 3)) +
  labs(shape = "Party", colour = "Party")
} # }