# NOT RUN {
# construct some data:
sampn <- 10000
testdata <- data.frame(
rowcat = paste0("1", sample(LETTERS[1:10], sampn, replace = TRUE)),
rowcat2 = paste0("2", sample(LETTERS[11:15], sampn, replace = TRUE)),
colcat = paste0("2", sample(letters[1:10], sampn, replace = TRUE)),
x = runif(sampn),
y = runif(sampn)
)
p <- ggplot2::ggplot(testdata) + ggplot2::aes(x=x, y=y, color=rowcat2) +
ggplot2::geom_point()
# plot the works (not actually recommended)
# }
# NOT RUN {
p + ggplot2::facet_grid(rowcat ~ colcat)
# }
# NOT RUN {
# plot a sample of the row-facets:
p + facet_sample(rowcat ~ colcat, sample_n = c(3, NA))
# plot a sample of the column-facets:
p + facet_sample(rowcat ~ colcat, sample_n = c(NA, 3))
# plot a sample of all facets:
p + facet_sample(rowcat ~ colcat, sample_n = c(3, 3))
# }
Run the code above in your browser using DataLab