Nothing
knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) library(highdir)
There are two ways to use highdir:
📝 Note
The
backend = "highcharter"orbackend = "ggplot2"argument inhd_make()andhd()functions will be replaced bymode = "dynamic"ormode = "static"repectively in a future release. Users of highdir ver 0.5.0 should continue to usebackend. The examples below use the forthcomingmodeargument.See the changelog for more information.
library(highdir) # Create dataset 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) ) # Figure data specification spec <- hd_spec(df, x = "age", y = "pct", group = "sex", n = "n") # Specify figure presentation opts <- hd_opts(title = "Tall om Report", subtitle = "Source: Example data", caption = "Tall om helse", ylim = c(0, 80)) hd_make(spec, "column", opts) # dynamic (default) hd_make(spec, "column", opts, mode = "static") # use backend for ver 0.5.0 hd_make(spec, "line", opts, smooth = TRUE) # smooth spline hd_make(spec, "pie", opts) # pie / donut # Disable JavaScript (for static HTML export) hd_make(spec, "column", opts, use_js = FALSE) # Save hd01 <- hd_make(spec, "column") hd_save(fig = hd01, file = "chart.html") gg01 <- hd_make(spec, "column", mode = "static") hd_save(fig = gg01, file = "chart.png")
# Interactive hd(df, x = "age", y = "pct", group = "sex", n = "n") + hd_geom_column() + hd_opts(title = "Tall om Report", subtitle = "Source: Example data", caption = "Tall om helse", ylim = c(0, 80)) # Static ggplot2 hd(df, x = "age", y = "pct", group = "sex", n = "n", mode = "static") + hd_geom_column() + hd_opts(title = "Tall om Report", subtitle = "Source: Example data", caption = "Tall om helse", ylim = c(0, 80))
For more example on how to use other geoms, please read in other geom examples
To list all geom features.
list_geoms()
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.