plot_results_bargraph: Plot Bar Graph Single Variable

View source: R/plot_results_bargraph.R

plot_results_bargraphR Documentation

Plot Bar Graph Single Variable

Description

This function takes a single variable result from a dataframe of results produced by healthyr::analyse_survey_results and creates a bar chart with confidence intervals. If specified can also produce grouped bar charts. Intended for use on already aggregated results, uses stat = "identity".

Usage

plot_results_bargraph(
  results_df,
  col_results,
  var_to_plot,
  var_to_group,
  file_path = NULL,
  wdth = NULL,
  hght = NULL,
  title_name = NULL
)

Arguments

results_df

Inputs a dataframe of results produced from the healthyr::analyse_survey_results function.

col_results

Inputs a character vector of column names that are formatted as results with CIs in square brackets.

var_to_plot

Inputs a character value specifying the variable to plot.

var_to_group

Inputs a character value specifying the variable to group by, for grouped bar charts.

file_path

Inputs an optional character value specifying the file path location to save an image of the plot. Recommended to specify as a .jpg or .png file.

wdth

Inputs an optional numeric value for the width of the image.

hght

Inputs an optional numeric value fo the height of the image.

title_name

Inputs an optional character value for the title of the plot.

Value

Returns a ggplot2 object.

Examples

## Not run: plot_results_bargraph(results_df, col_results = c(names(df[,-1]),
 var_to_plot = "gam_wfhz_noflag", var_to_group = "admin2") ))
## End(Not run)

SaeedR1987/healthyr documentation built on July 4, 2023, 11:17 p.m.