Description Usage Arguments Examples
facet_sample(...)
does layout as in facet_grid(...)
,
but samples facet(s) vice showing everything.
1 2 | facet_sample(..., sample_n = c(NA_integer_, NA_integer_),
seed = NA_integer_)
|
... |
future: changed default for |
sample_n |
a length 2 integer array, optionally with one value a future: a number between 0 and 1 will be treated as the fraction of options to be shown (converted to integer by ceiling) |
seed |
the random seed for drawing which rows & columns will be shown;
by default, this is The random number generator is reset for both rows and columns (with an offset) so,
with The seed for each dimension may be independently specified with a 2 element array. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | # 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)
# 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))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.