apexcharter/examples/compute-count.R

35 lines
677 B
R
Raw Normal View History

2020-12-31 09:46:32 +01:00
library(apexcharter)
data("mpg", package = "ggplot2")
### No grouping
# Both charts should be equivalent
2021-01-15 10:53:51 +01:00
n_manufac <- as.data.frame(table(
manufacturer = mpg$manufacturer
))
apex(data = n_manufac, type = "column", mapping = aes(x = manufacturer, y = Freq))
2020-12-31 09:46:32 +01:00
apex(data = mpg, type = "column", mapping = aes(x = manufacturer))
### With groups
# Both charts should be equivalent
2021-01-15 10:53:51 +01:00
n_manufac_year <- as.data.frame(table(
manufacturer = mpg$manufacturer,
year = mpg$year
))
apex(
data = n_manufac_year,
type = "column",
mapping = aes(x = manufacturer, y = n, fill = year)
)
apex(
data = mpg,
type = "column",
mapping = aes(x = manufacturer, fill = year)
)
2020-12-31 09:46:32 +01:00