Learn R Programming

visreg (version 3.0.0)

subset.visreg: Subset a visreg object

Description

Subset a visreg object so that only a portion of the full model is plotted.

Usage

# S3 method for visreg
subset(x, sub, ...)

Value

A visreg() object.

Arguments

x

A visreg object.

sub

Logical expression indicating elements to keep, as in subset()

...

Not used.

Examples

Run this code
# Fit a model and construct a visreg object
airquality$Heat <- cut(airquality$Temp, 3, labels = c("Cool", "Mild", "Hot"))
fit <- lm(Ozone ~ Solar.R + Wind * Heat, data = airquality)
v <- visreg(fit, "Wind", by = "Heat", plot = FALSE)

# Plot only certain levels
subset(v, Heat %in% c("Cool", "Hot")) |> plot()

# Plot only up to wind 15 mph
subset(v, Wind < 15) |> plot()

Run the code above in your browser using DataLab