ggbarmaker | R Documentation |
Makes quick and easy bar graphs for ggplot2 without pre-summarizing.
ggbarmaker( dv, groups, factor = NULL, id = NULL, groups_between = FALSE, palette = "Set1" )
dv |
Dependent variable vector |
groups |
Groups or first factor variable. |
factor |
Second factor variable. |
id |
The name of a varible that identifieseach subject for withins-subject designs. |
groups_between |
The 'groups' variable is a between subjects factor. |
palette |
Select RColorBrewer palette. |
You must manually adjust y-axis range using the ggplot2 function coord_cartesian().
Robert S. Chavez
# Between subject design. x <- rnorm(100,100,15) y <- sample(c("Group 1","Group 2"),100,TRUE) z <- sample(c("Low","Med","High"),100,TRUE) # Only one factor. ggbarmaker(x,y) # Two factors. ggbar.maker(x,y,z) # Within subject design x <- rnorm(100,100,15) y <- sample(c("Group 1","Group 2"),100,TRUE) z <- sample(c("Low","Med","High"),100,TRUE) subject <- rep(1:5,20) # No between subjects factors. ggbarmaker(x,y,z, id =subject) # Grouping factor is between subjects. ggbarmaker(x,y,z, id =subject, groups_between=TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.