The main features of this package are:
Various chart type with the same style: scatters, bubble, line, time series, heatmaps, treemap, bar charts, networks.
Chart various R object with one function. With hchart(x) you can chart: data.frames, numeric, histogram, character, density, factors, ts, mts, xts, stl, ohlc, acf, forecast, mforecast, ets, igraph, dist, dendrogram, phylo, survfit classes.
Support Highstock charts. You can create a candlestick charts in 2 lines of code. Support xts objects from the quantmod package.
Support Highmaps charts. It’s easy to create choropleths or add information in geojson format.
Themes: you configurate your chart in multiples ways. There are implemented themes like economist, financial times, google, 538 among others.
Plugins: motion, drag points, fontawesome, url-pattern, annotations.
This is a simple example using hchart function.
data(diamonds, mpg, package = "ggplot2")
hchart(mpg, "scatter", hcaes(x = displ, y = hwy, group = class))
The highcharts API
hc_chart(type = "column") %>%
hc_title(text = "A highcharter chart") %>%
hc_xAxis(categories = 2012:2016) %>%
hc_add_series(data = c(3900, 4200, 5700, 8500, 11900),
name = "Downloads")
Generic Function hchart
Among its features highcharter can chart various objects depending of its class with the generic2 hchart function.
hchart(diamonds$cut, colorByPoint = TRUE, name = "Cut")
hchart(diamonds$price, color = "#B71C1C", name = "Price") %>%
hc_title(text = "You can zoom me")
One of the nicest class which hchart can plot is the forecast class from the forecast package.
airforecast <- forecast(auto.arima(AirPassengers), level = 95)
With highcharter you can use the highstock library which include sophisticated navigation options like a small navigator series, preset date ranges, date picker, scrolling and panning. With highcarter it’s easy make candlesticks or ohlc charts using time series data. For example data from quantmod package.
x <- getSymbols("GOOG", auto.assign = FALSE)
hc_add_series(y, type = "ohlc")
You can chart maps and choropleth using the highmaps module.
hcmap("countries/us/us-all-all", data = unemployment,
name = "Unemployment", value = "value", joinBy = c("hc-key", "code"),
borderColor = "transparent") %>%
hc_colorAxis(dataClasses = color_classes(c(seq(0, 10, by = 2), 50))) %>%
hc_legend(layout = "vertical", align = "right",
floating = TRUE, valueDecimals = 0, valueSuffix = "%")
Now, let’s move on to the first set of real exercises on the highcharter package!
- Become a Top R Programmer Fast with our Individual Coaching Program
- Explore all our (>4000) R exercises
- Find an R course using our R Course Finder directory
- Subscribe to receive weekly updates and bonus sets by email
- Share with your friends and colleagues using the buttons below