Description Usage Arguments Value Examples
Compute and save layer datasets for a ggplot2 plot.
1 2 3 |
ggplot2 |
plot |
path |
Existing directory in which to save plot datasets. |
save_data
: (invisibly) a list that can be
transformed to JSON to produce vega data spec.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | p1 <- ggplot(mtcars, aes(disp, cyl)) +
geom_point()
str(plot_data(p1))
str(plot_data(p1 + geom_point(aes(y = cyl + 1))))
p2 <- p1 + geom_point(aes(displ * 61, cyl), data = mpg)
str(plot_data(p2))
p3 <- ggplot(mapping = aes(y = cyl)) +
geom_point(aes(disp, colour = "mtcars"), data = mtcars) +
geom_point(aes(displ * 61, colour = "mpg"), data = mpg)
str(plot_data(p3))
td <- temp_dir()
save_data(p3, td)
if (interactive()) show(td)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.