Skip to contents

Plot answers to a survey question using a horizontal bar chart using ggplot2.

Usage

plot_question(question, df, titles, nudge = 1, wrap = 20, themed = TRUE)

Arguments

question

name of column containing the question answers as a factor with specified levels.

df

data frame containing survey answers.

titles

named character vector mapping question column names to question titles.

nudge

amount of distance to nudge text label (percentage), passed on to ggplot2::geom_text() as nudge_x.

wrap

character width to wrap response labels, passed on to stringr::str_wrap() as width.

themed

apply default theme theme_quo(minor = TRUE) to the plot?

Examples

library(purrr)
#> 
#> Attaching package: ‘purrr’
#> The following object is masked from ‘package:scales’:
#> 
#>     discard

map(names(questions), plot_question, answers, questions, nudge = 0.25)
#> [[1]]

#> 
#> [[2]]

#> 
#> [[3]]

#>