ggbar: Simple bar chart with ECDC colours

Description Usage Arguments Author(s) See Also Examples

View source: R/ggbar.R

Description

Somewhat pipe (dplyr) friendly bar chart. Allows a stacked bar chart with groupings.

Usage

1
2
ggbar(data, xvar, group = NULL, col_scale = c("qualitative", "green",
  "blue", "red"), xtitle = xvar, ytitle = "count", legend_title = group)

Arguments

data

Your data frame

group

vector in your dataframe, given without quotes

col_scale

colour scale, defaults to "qualitative"

xtitle

x axis title, defaults to x

ytitle

y axis title, defaults to "count"

legend_title

legend title, if applicable defaults to group

x

vector in your dataframe, given without quotes

Author(s)

Tommi Karki

See Also

ggplot2

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
Create dummy data
mydat <- data.frame(ID = c(seq(1,10,1)),
Gender = c(rep(c("F", "M"),5)),
AgeGroup = c(rep(c("0-18", "18-65", "65+"),3), "65+"),
Case = c(1,1,1,0,0,1,1,1,1,1),
DateOfOnset = as.Date(c("2017-06-11", "2017-06-11", 
                       "2017-06-11", NA, NA, "2017-06-10", 
                       "2017-06-14", "2017-06-14",
                       "2017-06-19", "2017-06-19")),
Month = c(sample(c(3:6),5, replace = TRUE), sample(c(1:12),5)),
Week = c(sample(c(10:12),5, replace = TRUE), sample(c(1:53),5)))

bar(mydat, Gender)

#Stacked bar by AgeGroup
bar(mydat, Gender, group = AgeGroup)

TommiKarki/EpiMethods documentation built on Dec. 6, 2019, 4:48 a.m.