gglikert: Generate a ggplot2 for a likert 5-scale question.

Description Usage Arguments Details Value Examples

View source: R/gglikert.R

Description

The function generates a bar chart with fill colors determined by likert 5-point scale. The chart includes labels with the proportion, labels with averages (1-5) on top of bars, and the fill is red-yellow-green colored.

Usage

1
2
3
4
5
6
7
8
9
gglikert(
  x,
  axis.x.wrap = 12,
  wrap_RTL = F,
  likert_scale_labels = c("1 - Extremely\nDissatisfied", 2:4,
    "5 - Extremely\nSatisfied"),
  likert_scale_fill = "RdYlGn",
  likert_scale_numeric = 1:5
)

Arguments

x

a tbl() with the data.

axis.x.wrap

The x.axis text wrap.

wrap_RTL

If T, uses unicode characters to have the text wrap fitted for RTL languages (e.g., Hebrew and Arabic). This parameter is also required to preserve UTF-8 encoding when using Hebrew.

likert_scale_labels

The labels for the likert scale. The default is a 5-point likert scale with "1 - Extremely Dissatisfied", 2:4, "5 - Extremely Satisfied".

likert_scale_fill

Provide scale to be used. Makes colors consistent, even if some levels Are missing from data. Defaults to brewer "RdYlGn".

likert_scale_numeric

Controls the numeric values related to the likert, for example, can be modified to a 1-7 likert scale by using 1:7 along with the proper updates to the likert_scale_labels

Details

The function uses the raw data in a tabular format (each column is a variable). NAs as omitted.

Assumes that the columns are numeric with values 1-5.

Value

A ggplot2 as specified above.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
satisfaction <- tribble(
  ~general, ~staff, ~professionalism,
  5, 5, 4,
  3, 2, 3,
  4, 5, 5,
  1, 2, 2,
  3, 3, 4
  )
gglikert(satisfaction)

# You may also define your own text for the legend

gglikert(satisfaction, likert_scale_labels = c("not at all", "low", "somewhat", "very", "extremely"))

sarid-ins/saridr documentation built on Nov. 10, 2020, 9:07 p.m.