Learn R Programming

flashlight (version 0.7.5)

plot.light_profile: Visualize Profiles, e.g. of Partial Dependence

Description

Minimal visualization of an object of class light_profile. The object returned is of class ggplot and can be further customized.

Usage

# S3 method for light_profile
plot(
  x,
  swap_dim = FALSE,
  facet_scales = "free_x",
  rotate_x = x$type != "partial dependence",
  show_points = TRUE,
  ...
)

Arguments

x

An object of class light_profile.

swap_dim

If multiflashlight and one "by" variable or single flashlight with two "by" variables, swap the role of dodge/fill variable and facet variable. If multiflashlight or one "by" variable, use facets instead of colors.

facet_scales

Scales argument passed to facet_wrap.

rotate_x

Should x axis labels be rotated by 45 degrees? TRUE, except for type "partial dependence".

show_points

Should points be added to the line (default is TRUE).

...

Further arguments passed to geom_point and geom_line.

Value

An object of class ggplot2.

Details

Either lines and points are plotted (if stats = "mean") or quartile boxes. If there is a "by" variable or a multiflashlight, this first dimension is taken care by color (or if swap_dim = TRUE by facets). If there are two "by" variables or a multiflashlight with one "by" variable, the first "by" variable is visualized as color, the second one or the multiflashlight via facet (change with swap_dim).

See Also

light_profile, plot.light_effects.

Examples

Run this code
# NOT RUN {
fit <- lm(Sepal.Length ~ ., data = iris)
fl <- flashlight(model = fit, label = "iris", data = iris, y = "Sepal.Length")
plot(light_profile(fl, v = "Species"))
plot(light_profile(fl, v = "Petal.Width", by = "Species", evaluate_at = 2:4))
plot(light_profile(fl, v = "Petal.Width", type = "predicted"))
# }

Run the code above in your browser using DataLab