The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

Quick start

There are two ways to use highdir:

  1. Declarative API approach
  2. Layered API approach

Declarative API


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)                       # highcharter (default)
hd_make(spec, "column", opts, backend = "ggplot2")  # static ggplot2
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", backend = "ggplot2")
hd_save(fig = gg01, file = "chart.png")

Layered API


# 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", backend = "ggplot2") +
  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

Geom

To list all geom features.

list_geoms()
#> [1] "arearange"      "column"         "line"           "pie"           
#> [5] "ranked_bar"     "scatter"        "stacked_column"

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.