plot_bar: Function which returns plot of averages, standard devations,...

View source: R/plot_bar.R

plot_barR Documentation

Function which returns plot of averages, standard devations, and points

Description

Function takes in a database, and plots points based on 3 variables - y-axis, x-axis, and grouping. Function calculates standard deviations and means by group and point on x-axis. Only y-axis needs to be numeric, but if you want to ensure the x-axis are ordered correctly, I suggest ordering it before plotting

Usage

plot_bar(
  data,
  x,
  y,
  by,
  title = "",
  bar_color,
  point_color = "black",
  errorbar_color = "grey4",
  geom = "bar",
  points = TRUE,
  percentile = 0,
  color_by = x
)

Arguments

data

- database to pull from

x

- this is the GROUPING (e.g. sex)

y

- this is the outcome variable

by

- this is the facet_wrap that appears as the x-axis (e.g. age in months)

title

- OPTIONALnplot title

bar_color

- OPTIONAL color of bars indicating averages (you could switch it, it is just the parameter you pass to 'geom'). Needs to be the same length as unique(data$x)

point_color

- OPTIONAL color of points. List needs to be the same length as bar_color. Default is black

errorbar_color

- OPTIONAL color of errorbars (standard deviation). Default is grey4 (almost black)

geom

- OPTIONAL to pass to 'geom'. Default is bar

points

- OPTIONAL. Default is TRUE. Whether or not it shows points

percentile

- this refers to which points you don't want to plot. For example, if it is set to 0.05, meaning that 5 lowest points don't get plotted. Default is 0, so no points get removed

color_by

- OPTIONAL, do you want to color the by x or by the by variable? Default is x

Value

Plot

Author(s)

.....


wfmueller29/SLAM documentation built on April 5, 2025, 5:09 a.m.