Skip to contents

hchart uses highchart to draw a particular plot for an object of a particular class in a single command. This defines the S3 generic that other classes and packages can extend.

Usage

hchart(object, ...)

# S3 method for class 'CausalImpact'
hchart(object, ...)

# S3 method for class 'decomposed.ts'
hchart(object, ...)

# S3 method for class 'prcomp'
hchart(object, ..., choices = 1:2, scale = 1, loadings = FALSE, label = FALSE)

# S3 method for class 'princomp'
hchart(object, ..., choices = 1:2, scale = 1, loadings = FALSE, label = FALSE)

Arguments

object

A R object.

...

Additional arguments for the data series (https://api.highcharts.com/highcharts/series).

choices

Two component numbers to plot on the x and y axes.

scale

PCA score scaling exponent between 0 and 1. Zero plots raw scores.

loadings

Draw and name the variable loading vectors on the PCA plot.

label

Display observation names on PCA points.

Details

Run methods(hchart) to see what objects are supported. Numeric matrices use a heatmap by default. Set type = "tilemap" for hexagonal tiles or type = "contour" for contour lines. Empirical distributions from stats::ecdf() use step = "left" to show jumps at observations. Pass step = FALSE to restore ordinary line interpolation. Matrix heatmaps put row one at the top. Use hc_yAxis(reversed = FALSE) to restore the usual axis direction. A matrix with negative values and all entries between -1 and 1 gets a diverging color scale spanning that interval. Use hc_colorAxis() to supply different limits and color stops. One-way tables use columns in category order. Two-way tables use the matrix heatmap. Use margin.table() to choose dimensions of a larger table.

For a GeoJSON FeatureCollection from geojsonio, each geometry family gets its own layer. Supply type to select one layer explicitly.

A CausalImpact fit shows the observed response and counterfactual prediction, the pointwise effect and the cumulative effect. Shaded bands show the model's posterior intervals. A vertical line marks the start of the post-intervention period.

See also

hchart.constparty() and hchart.xgb.Booster() for decision trees, hchart.randomForest() and hchart.cv.glmnet() for model diagnostics, and hchart.hclust() for dendrograms and phylogenies.

Examples

methods(hchart)
#>  [1] hchart.C5.0*          hchart.CausalImpact*  hchart.acf*          
#>  [4] hchart.character*     hchart.constparty*    hchart.cv.glmnet*    
#>  [7] hchart.data.frame*    hchart.decomposed.ts* hchart.default*      
#> [10] hchart.dendrogram*    hchart.density*       hchart.dist*         
#> [13] hchart.ecdf*          hchart.ets*           hchart.factor*       
#> [16] hchart.forecast*      hchart.geo_json*      hchart.geo_list*     
#> [19] hchart.hclust*        hchart.histogram*     hchart.igraph*       
#> [22] hchart.list*          hchart.matrix*        hchart.mforecast*    
#> [25] hchart.mts*           hchart.numeric*       hchart.phylo*        
#> [28] hchart.prcomp*        hchart.princomp*      hchart.randomForest* 
#> [31] hchart.rpart*         hchart.seas*          hchart.stl*          
#> [34] hchart.survfit*       hchart.table*         hchart.ts*           
#> [37] hchart.xgb.Booster*   hchart.xts*          
#> see '?methods' for accessing help and source code

# Principal component analysis
fit <- stats::prcomp(USArrests, scale. = TRUE)
hchart(fit)
# Classification tree: each donut shows the species proportions in a node tree <- partykit::ctree(Species ~ Petal.Length + Petal.Width, data = iris) hchart(tree)
# An igraph network net <- igraph::make_graph("Zachary") hchart(net, layout = igraph::layout_with_kk)