mosaic (version 1.1.0)

mplot: Generic plotting

Description

Generic function plotting for R objects. Currently plots exist for data.frames, lms, (including glms).

Usage

mplot(object, ...)

# S3 method for default mplot(object, ...)

# S3 method for lm mplot(object, which = c(1:3, 7), system = c("lattice", "ggplot2", "base"), ask = FALSE, multiplot = "package:gridExtra" %in% search(), par.settings = theme.mosaic(), level = 0.95, title = paste("model: ", deparse(object$call), "\n"), rows = TRUE, ...)

# S3 method for data.frame mplot(object, format, default = format, system = c("lattice", "ggplot2"), show = FALSE, title = "", ...)

# S3 method for summary.lm mplot(object, system = c("lattice", "ggplot2"), level = 0.95, par.settings = trellis.par.get(), rows = TRUE, ...)

# S3 method for TukeyHSD mplot(object, system = c("lattice", "ggplot2"), 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"), ...)

Arguments

object

an R object from which a plot will be constructed.

...

additional arguments. If object is an lm, subsets of these arguments are passed to grid.arrange and to the lattice plotting routines; in particular, nrow and ncol can be used to control the number of rows and columns used.

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 ask == FALSE, all plots will be displayed together.

par.settings

lattice theme settings

level

a confidence level

title

title for plot

rows

rows to show. This may be a numeric vector, TRUE (for all rows), or a character vector of row names.

format, default

default type of plot to create; one of "scatter", "jitter", "boxplot", "violin", "histogram", "density", "frequency polygon", or "map". Unique prefixes suffice.

show

a logical, if TRUE, the code will be displayed each time the plot is changed.

ylab

label for y-axis

xlab

label for x-axis

order

one of "pval", "diff", or "asis" determining the order of the pair factor, which determines the order in which the differences are displayed on the plot.

data

a data frame containing the variables that might be used in the plot.

Value

Nothing. Just for side effects.

Details

The method for models (lm and glm) is still a work in progress, but should be useable 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.

Examples

Run this code
# NOT RUN {
mplot( lm( width ~ length * sex, data=KidsFeet) )
mplot( lm( width ~ length * sex, data=KidsFeet), rows=2:3, which=7 )
# }
# NOT RUN {
mplot( HELPrct )
mplot( HELPrct, "histogram" )
# }
# NOT RUN {
mplot(summary(lm(width ~ length * sex, data=KidsFeet)), system="ggplot2")
mplot(summary(lm(width ~ length * sex, data=KidsFeet)), rows=c("sex", "length"))
mplot(summary(lm(width ~ length * sex, data=KidsFeet)), rows=TRUE)
mplot(TukeyHSD( lm(age ~ substance, data=HELPrct) ) )
mplot(TukeyHSD( lm(age ~ substance, data=HELPrct) ), system="ggplot2" )
# }

Run the code above in your browser using DataCamp Workspace