Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library(ggplot2)
- Unit <- c("A", "B", "C", "D") #character objects need quotes
- Yes <- c(50, 65, 20, 41)
- No <- c(70, 67, 40, 20)
- Missing <- c(10, 12, 8, 7)
- df <- data.frame(Unit, Yes, No, Missing)
- require(tidyr)
- df.long <- gather(df, Unit)
- colnames(df.long) <- c("Unit", "variable", "value")
- ggplot(data = df.long, aes(x = Unit, y = value, fill = variable)) +
- geom_col(position = position_dodge())
Add Comment
Please, Sign In to add comment