Created
June 21, 2013 18:44
-
-
Save Ram-N/5833375 to your computer and use it in GitHub Desktop.
Example to understand how facet_wrap and facet_grid work.
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(ggplot2) | |
unique(diamonds$cut) | |
unique(diamonds$clarity) | |
names(diamonds) | |
dim(diamonds) | |
g <- ggplot(diamonds[1:1000,]) + geom_point(aes(x=carat, y=price)) | |
g <- g + facet_grid(. ~ cut) #horizontal stacking | |
g <- g + facet_grid(cut ~ .) #vertical stacking | |
g <- g + facet_grid(clarity ~ cut) #vertical stacking | |
g <- g + facet_wrap(clarity ~ cut) #good for exploring interesting cases | |
g |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment