sp_facet {SveltePlots} | R Documentation |
Create Multiple Charts Based on a Faceting Variable
Description
This function creates multiple charts based on a specified faceting variable.
Usage
sp_facet(sp, ncol = NULL, nrow = NULL, scales = "fixed")
Arguments
sp |
A SveltePlot htmlwidget object. |
ncol |
The number of columns in the facet grid. Default is NULL, which auto-calculates based on the number of rows. |
nrow |
The number of rows in the facet grid. Default is NULL, which auto-calculates based on the number of columns. |
scales |
A character string specifying whether scales are shared across all facets. Options are "fixed" (default) or "free". |
Details
This function splits the data by the specified facet variable and creates multiple charts (facets) accordingly. The function can automatically determine the number of rows and columns in the facet grid if not specified.
Value
An object of class htmlwidget
representing the facetted plot.
Examples
library(SveltePlots)
data("penguins")
sp <- sp(
data = penguins,
mapping = spaes(x = flipper_length_mm, y = bill_length_mm, group = species),
type = "points",
facet_var = "sex"
) |>
SveltePlots::sp_facet(ncol = 2, scales = "free")
sp
[Package SveltePlots version 0.1.0 Index]