Setup:
library(plyr)
d <- ldply(setNames(nm=8:10), function(y) data.frame(x=y, y=y))
d
## .id x y
## 1 8 8 8
## 2 9 9 9
## 3 10 10 10
After latest changes to plyr, the .id column is a factor:
summary(d)
## .id x y
## 8 :1 Min. : 8.0 Min. : 8.0
## 9 :1 1st Qu.: 8.5 1st Qu.: 8.5
## 10:1 Median : 9.0 Median : 9.0
## Mean : 9.0 Mean : 9.0
## 3rd Qu.: 9.5 3rd Qu.: 9.5
## Max. :10.0 Max. :10.0
Doesn't work with facet_wrap:
library(ggplot2)
ggplot(d, aes(x=x, y=y)) + facet_grid(~.id) + geom_point()
Session info:
sessionInfo()
## R version 3.0.2 (2013-09-25)
## Platform: x86_64-pc-linux-gnu (64-bit)
##
## locale:
## [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
## [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
## [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
## [7] LC_PAPER=en_US.UTF-8 LC_NAME=C
## [9] LC_ADDRESS=C LC_TELEPHONE=C
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] ggplot2_0.9.3.1.99 plyr_1.8.0.99 knitr_1.5.15
##
## loaded via a namespace (and not attached):
## [1] colorspace_1.2-4 dichromat_2.0-0 digest_0.6.4
## [4] evaluate_0.5.2 formatR_0.10.3 grid_3.0.2
## [7] gtable_0.1.2 labeling_0.2 MASS_7.3-29
## [10] munsell_0.4.2 proto_0.3-10 RColorBrewer_1.0-5
## [13] Rcpp_0.10.6 reshape2_1.2.2 scales_0.2.3.99
## [16] stringr_0.6.2 tools_3.0.2