Description Usage Arguments Author(s) See Also Examples
Somewhat pipe (dplyr) friendly bar chart. Allows a stacked bar chart with groupings.
1 2 |
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 |
Tommi Karki
ggplot2
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.