bar.plot {figuRes2}R Documentation

bar.plot

Description

A function for creating harmonized ggplot2 bar charts

Usage

bar.plot(
  parent.df,
  category.col = "TRTGRP",
  category.label = "Treatment Group",
  x.label = "",
  y.col = "GWHRT",
  y.label = "Percentage of Subjects",
  y.limits = c(0, 0.7),
  y.ticks = seq(0, 0.3, 0.05),
  bar.position = "dodge",
  category.palette = c("red", "blue"),
  text.size = 3,
  text.buffer = 0.05,
  killMissing = TRUE
)

Arguments

parent.df

data.frame used by ggplot

category.col

data.frame column associated with categorical variable (bar.plot, box.plot, cdf.plot, dot.plot, km.plot)

category.label

passed to x-axis label

x.label

value gets passed to labs

y.col

parent.df column associated with response vairable

y.label

value gets passed to labs

y.limits

passed to scale_y_continuous

y.ticks

passed to scale_y_continuous

bar.position

passed to geom_bar (bar.plot)

category.palette

colors assoicated with categorical variable

text.size

value gets passed to geom_text

text.buffer

used by bar.plot to control text placement

killMissing

logical used by bar.plot

Value

A ggplot object is returned.

Author(s)

Greg Cicconetti

Examples

{
# Access dummy demography dataset
data(demog.data)
levels(demog.data$SEX) <- c("Female", "Male")

# A ggplot object is returned
p1 <- bar.plot(parent.df = demog.data, y.col = "SEX", 
x.label= "Gender", y.label = "Percentage of Subjects", 
category.col = "REGION", category.label = "Region", 
y.limits = c(0, 0.35), y.ticks = seq(0, 0.5, 0.05), 
bar.position= "dodge", 
category.palette = RColorBrewer::brewer.pal(n=5, name = "Dark2"),
text.size =4, text.buffer=.025, killMissing = TRUE) 
print(p1)
} 

[Package figuRes2 version 1.0.0 Index]