Created
March 6, 2009 01:24
-
-
Save hadley/74686 to your computer and use it in GitHub Desktop.
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
measure <- structure(list(age = structure(c(1L, 2L, 3L, 4L, 1L, 2L, 3L, | |
4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L), .Label = c("7-yrs", "11-yrs", | |
"15-yrs", "21-yrs"), class = "factor"), trt = structure(c(2L, | |
2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L), .Label = c("alternation", | |
"repetition"), class = "factor"), value = c(814, 500, 424, 394, | |
967, 574, 472, 446, 10, 6, 6, 4, 13, 7, 6, 3), variable = c("rt", | |
"rt", "rt", "rt", "rt", "rt", "rt", "rt", "error", "error", "error", | |
"error", "error", "error", "error", "error")), .Names = c("age", | |
"trt", "value", "variable"), row.names = c(NA, 16L), class = "data.frame") | |
plot <- ggplot(measure, aes(age, value, colour = trt, fill = trt)) + | |
facet_grid(variable ~ . , scale = "free") | |
plot + geom_bar(position = "dodge") | |
plot + geom_line(aes(group = trt)) + geom_point() | |
# It's then just a matter of combining the two: | |
plot + | |
geom_bar(position = "dodge", subset = variable == "rt") + | |
geom_line(aes(group = trt), subset = variable == "error") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment