Skip to contents

horzBarChart() creates a horizontal bar chart and returns a ggplot object with Blackstone Research and Evaluation branding.

Usage

horzBarChart(df, percent_label = TRUE, width = NULL)

Arguments

df

Required, a tibble/data frame that has been pre-processed with dataSumm().

percent_label

Logical, default is TRUE. If FALSE, labels the bars with the number of answers per response.

width

Input a value between 0.3 and 0.8 to set the thickness of the bars. Default is NULL.

Value

A ggplot2 object that plots the items into a horizontal bar chart and can be exported.

Examples

data <- dplyr::tibble(
  role = c(
    "Faculty", "Postdoc", "Undergraduate student", "Graduate student",
    "Graduate student", "Postdoc", "Postdoc", "Faculty",
    "Faculty", "Graduate student", "Graduate student", "Postdoc",
    "Faculty", "Faculty", "Faculty", "Faculty", "Faculty", "Graduate student",
    "Undergraduate student", "Undergraduate student"
  )
)
# Set up the data by passing the item to chart to blackstone::dataSumm():
role_summ <- data %>%
  dplyr::select(role) %>%
  blackstone::dataSumm()
# Calling horzBarChart() with defaults, labels for bars are percentage labels:
horzBarChart(role_summ)
#> Warning: font family 'Arial' not found in PostScript font database
#> Warning: font family 'Arial' not found in PostScript font database
#> Warning: font family 'Arial' not found in PostScript font database
#> Warning: font family 'Arial' not found in PostScript font database
#> Warning: font family 'Arial' not found in PostScript font database
#> Warning: font family 'Arial' not found in PostScript font database
#> Warning: font family 'Arial' not found in PostScript font database
#> Warning: font family 'Arial' not found in PostScript font database
#> Warning: font family 'Arial' not found in PostScript font database
#> Warning: font family 'Arial' not found in PostScript font database
#> Warning: font family 'Arial' not found in PostScript font database
#> Warning: font family 'Arial' not found in PostScript font database
#> Warning: font family 'Arial' not found in PostScript font database
#> Warning: font family 'Arial' not found in PostScript font database
#> Warning: font family 'Arial' not found in PostScript font database
#> Warning: font family 'Arial' not found in PostScript font database
#> Warning: font family 'Arial' not found in PostScript font database
#> Warning: font family 'Arial' not found in PostScript font database
#> Warning: font family 'Arial' not found in PostScript font database
#> Warning: font family 'Arial' not found in PostScript font database
#> Warning: font family 'Arial' not found in PostScript font database
#> Warning: font family 'Arial' not found in PostScript font database
#> Warning: font family 'Arial' not found in PostScript font database
#> Warning: font family 'Arial' not found in PostScript font database
#> Warning: font family 'Arial' not found in PostScript font database
#> Warning: font family 'Arial' not found in PostScript font database
#> Warning: font family 'Arial' not found in PostScript font database
#> Warning: font family 'Arial' not found in PostScript font database
#> Warning: font family 'Arial' not found in PostScript font database
#> Warning: font family 'Arial' not found in PostScript font database
#> Warning: font family 'Arial' not found in PostScript font database

# Calling horzBarChart() with percent_label set to FALSE will labels the bars with counts:
horzBarChart(role_summ, percent_label = FALSE)
#> Warning: font family 'Arial' not found in PostScript font database
#> Warning: font family 'Arial' not found in PostScript font database
#> Warning: font family 'Arial' not found in PostScript font database
#> Warning: font family 'Arial' not found in PostScript font database
#> Warning: font family 'Arial' not found in PostScript font database
#> Warning: font family 'Arial' not found in PostScript font database
#> Warning: font family 'Arial' not found in PostScript font database
#> Warning: font family 'Arial' not found in PostScript font database
#> Warning: font family 'Arial' not found in PostScript font database
#> Warning: font family 'Arial' not found in PostScript font database
#> Warning: font family 'Arial' not found in PostScript font database
#> Warning: font family 'Arial' not found in PostScript font database
#> Warning: font family 'Arial' not found in PostScript font database
#> Warning: font family 'Arial' not found in PostScript font database
#> Warning: font family 'Arial' not found in PostScript font database
#> Warning: font family 'Arial' not found in PostScript font database
#> Warning: font family 'Arial' not found in PostScript font database