mplot | R Documentation |
Generic function plotting for R objects. Currently plots exist for
data.frame
s, lm
s, (including glm
s).
mplot(object, ...)
## Default S3 method:
mplot(object, ...)
## S3 method for class 'lm'
mplot(
object,
which = c(1:3, 7),
system = c("ggplot2", "lattice", "base"),
ask = FALSE,
multiplot = "package:gridExtra" %in% search(),
par.settings = theme.mosaic(),
level = 0.95,
title = paste("model: ", deparse(object$call), "\n"),
rows = TRUE,
id.n = 3L,
id.size = 5,
id.color = "red",
id.nudge = 1,
add.smooth = TRUE,
smooth.color = "red",
smooth.alpha = 0.6,
smooth.size = 0.7,
span = 3/4,
...
)
## S3 method for class 'data.frame'
mplot(
object,
format,
default = format,
system = c("ggformula", "ggplot2", "lattice"),
show = FALSE,
data_text = rlang::expr_deparse(substitute(object)),
title = "",
...
)
## S3 method for class 'summary.lm'
mplot(
object,
system = c("ggplot2", "lattice"),
level = 0.95,
par.settings = trellis.par.get(),
rows = TRUE,
...
)
## S3 method for class 'TukeyHSD'
mplot(
object,
system = c("ggplot2", "lattice"),
ylab = "",
xlab = "difference in means",
title = paste0(attr(object, "conf.level") * 100, "% family-wise confidence level"),
par.settings = trellis.par.get(),
order = c("asis", "pval", "difference"),
...
)
object |
an R object from which a plot will be constructed. |
... |
additional arguments. If |
which |
a numeric vector used to select from 7 potential plots |
system |
which graphics system to use (initially) for plotting (ggplot2 or lattice). A check box will allow on the fly change of plotting system. |
ask |
if TRUE, each plot will be displayed separately after the user responds to a prompt. |
multiplot |
if TRUE and |
par.settings |
lattice theme settings |
level |
a confidence level |
title |
title for plot |
rows |
rows to show. This may be a numeric vector,
|
id.n |
Number of id labels to display. |
id.size |
Size of id labels. |
id.color |
Color of id labels. |
id.nudge |
a numeric used to increase (>1) or decrease (<1) the amount that observation labels are nudged. Use a negative value to nudge down instead of up. |
add.smooth |
A logicial indicating whether a LOESS smooth should be added (where this makes sense to do). Currently ignored for lattice plots. |
smooth.color , smooth.size , smooth.alpha |
Color, size, and alpha used for LOESS curve. Currently ignored for lattice plots. |
span |
A positive number indicating the amount of smoothing.
A larger number indicates more smoothing. See |
format , default |
default type of plot to create; one of
|
show |
a logical, if |
data_text |
text representation of the data set. In typical use cases, the default value should suffice. |
ylab |
label for y-axis |
xlab |
label for x-axis |
order |
one of |
data |
a data frame containing the variables that might be used in the plot. |
The method for models (lm and glm) is still a work in progress, but should be usable for
relatively simple models. When the results for a logistic regression model created with
glm()
are satisfactory will depend on the format and structure of the data
used to fit the model.
Due to a bug in RStudio 1.3, the method for data frames may not display the controls consistently. We have found that executing this code usually fixes the problem:
library(manipulate) manipulate(plot(A), A = slider(1, 10))
Nothing. Just for side effects.
lm( width ~ length * sex, data = KidsFeet) |>
mplot(which = 1:3, id.n = 5)
lm( width ~ length * sex, data = KidsFeet) |>
mplot(smooth.color = "blue", smooth.size = 1.2, smooth.alpha = 0.3, id.size = 3)
lm(width ~ length * sex, data = KidsFeet) |>
mplot(rows = 2:3, which = 7)
## Not run:
mplot( HELPrct )
mplot( HELPrct, "histogram" )
## End(Not run)
lm(width ~ length * sex, data = KidsFeet) |>
summary() |>
mplot()
lm(width ~ length * sex, data = KidsFeet) |>
summary() |>
mplot(rows = c("sex", "length"))
lm(width ~ length * sex, data = KidsFeet) |>
summary() |>
mplot(rows = TRUE)
lm(age ~ substance, data = HELPrct) |>
TukeyHSD() |>
mplot()
lm(age ~ substance, data = HELPrct) |>
TukeyHSD() |>
mplot(system = "lattice")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.