| slim_data | R Documentation |
Remove unused columns from the data in a ggplot or patchwork object. This function keeps only the columns that are actually used in the plot (e.g., in mappings, aesthetics, or facets), which can significantly reduce the object size when the original data contains many unused columns.
slim_data(p)
## S3 method for class 'ggplot'
slim_data(p)
## S3 method for class 'patchwork'
slim_data(p)
p |
A |
A ggplot or patchwork object with unused data columns removed.
library(ggplot2)
p <- ggplot(
data = mtcars,
aes(x = mpg, y = wt, colour = cyl)
) +
geom_point()
object.size(p)
colnames(p$data)
p_slim <- slim_data(p)
object.size(p_slim)
colnames(p_slim$data)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.