| hd_spec | R Documentation |
Defines the data mapping for a figure - which columns map to x, y,
group, and count - independently of any visual presentation choices.
Pass the result to hd_make() together with an optional hd_opts()
object.
hd_spec(data = NULL, x, y, group = NULL, n = NULL, colour = NULL)
data |
A |
x |
Character. Column name for the x-axis variable. |
y |
Character. Column name for the y-axis variable (typically a percentage or count). |
group |
Character or |
n |
Character or |
colour |
Character or |
An S3 object of class "hd_spec".
hd_opts(), hd_make()
df <- data.frame(
age = rep(c("18-24", "25-34", "35-44", "45-54"), each = 2),
sex = rep(c("Male", "Female"), 4),
pct = c(42, 38, 55, 61, 48, 52, 60, 57),
n = c(120, 115, 200, 210, 180, 175, 160, 155)
)
spec <- hd_spec(df, x = "age", y = "pct", group = "sex", n = "n")
spec
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.