Last active
December 29, 2015 07:19
-
-
Save lukmdo/7634956 to your computer and use it in GitHub Desktop.
R multibar plot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(Hmisc) # summarize | |
dx = summarize(mtcars$hp, llist(mtcars$cyl, mtcars$gear), sum) | |
dx = summarize(mtcars$hp, llist(mtcars$cyl, mtcars$gear), mean) | |
names(dx) = c("cyl", "gear", "hp") | |
dx.t = xtabs(hp ~ cyl + gear, dx) | |
barplot(dx.t, | |
beside=T, | |
col=rainbow(3), | |
xlab="gear", ylab="Mean(hp)", | |
legend = rownames(dx.t) | |
args.legend = list(x="topleft", title="Num cyl")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment