library(visreg) knitr::opts_knit$set(aliases=c(h = 'fig.height', w = 'fig.width')) knitr::opts_chunk$set(comment='#', collapse=TRUE, cache=FALSE, tidy=FALSE) knitr::knit_hooks$set(small.mar = function(before, options, envir) { if (before) par(mar = c(4, 4, .1, .1)) })
fit <- lm(Ozone ~ Solar.R + Wind + Temp, data=airquality)
and then you pass it to visreg
:
visreg(fit, "Wind")
A more complex example, which uses the gam()
function from mgcv:
library(mgcv) airquality$Heat <- cut(airquality$Temp, 3, labels=c("Cool", "Mild", "Hot")) fit <- gam(Ozone ~ s(Wind, by=Heat, sp=0.1), data=airquality) visreg(fit, "Wind", "Heat", gg=TRUE, ylab="Ozone")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.