pkgdown is an R package that makes it easy to build a web site for your package. However, the current version 1.6.1 on CRAN doesn’t work so well for packages whose examples use RGL or other packages like leaflet that use htmlwidgets. This document describes current progress in supporting both of these.
The main problem for pkgdown
support is that RGL and other htmlwidgets users require multiple
1.6.1 can’t do this, but the current development version on Github adds
support for additional dependent libraries. This also require downlit version 0.4.0 or
Installing the changes is fairly easy. Make sure you have the remotes package installed, then run
::install_github(c("rstudio/webshot2", remotes"rstudio/chromote", "r-lib/pkgdown"))
With these development version packages installed, you should see RGL
leaflet output appear automatically in examples. The RGL
output is set up to mimic what would happen in a
document that uses
setupKnitr(autoprint = TRUE)
i.e. the output RGL commands will automatically be included in the display. Low-level changes will be collected into a single display:
# Show regression plane with z as dependent variable library(rgl) open3d()
## null ## 15
<- rnorm(100) x <- rnorm(100) y <- 0.2*x - 0.3*y + rnorm(100, sd = 0.3) z <- lm(z ~ x + y) fit plot3d(x, y, z, type = "s", col = "red", size = 1) # No plot here, because of the planes3d() call below <- coef(fit) coefs <- coefs["x"] a <- coefs["y"] b <- -1 c <- coefs["(Intercept)"] d planes3d(a, b, c, d, alpha = 0.5)
By default, pkgdown generates standard plots which are wider than they are high (according to the golden ratio). Often RGL plots look better with equal width and height, since the contents may be rotated by the user.
To specify the size of plots in pkgdown, you use the
figures entry in
_pkgdown.yml. The defaults
are similar to
figures: dev: ragg::agg_png dpi: 96 dev.args:  fig.ext: png fig.width: 7 fig.height: ~ fig.retina: 2 fig.asp: 1.618 bg: NA other.parameters: 
By default RGL uses these parameters as well, but allows you to
override any of
fig.asp by specifying an
rgl entry in
other.parameters. For example:
figures: fig.width: 5 other.parameters: rgl: fig.asp: 1
This will make all plots have a width of 5 inches and will make RGL plots square.
These are development versions of the packages, so they may contain bugs, either in my changes or in other unreleased changes. I don’t recommend you use them in regular production code. To re-install released versions of the packages, run
If you do use them and notice any bugs, please report them!