Skip to contents

This is a generic function for plotting 'R' objects using the Chart.js charting library. The syntax is similar to that of the plot() generic function.

Usage

plotjs(x, ...)

Arguments

x

x coordinates for points or any 'R' object with a plotjs method.

...

arguments passed to methods.

Details

For simple scatter and line plots, plotjs.default will be used. However, there are plotjs methods for various 'R' objects. Use methods(plotjs) and the documentation for these.

Plots created with this are interactive htmlwidgets that can be used in the RStudio Viewer or embedded into 'R Markdown' documents, 'Shiny' web applications, etc.

For the default method, the argument y with the y coordinates of points is required. For some methods, such as plotjs.density and plotjs.function, y is not required because those methods can compute or extract y coordinates from the x object.

Examples

data(mtcars)
plotjs(mtcars$disp, mtcars$hp, main = "Displacement vs. HP in mtcars")
plotjs(qnorm)