mosaic {regclass}R Documentation

Mosaic plot

Description

Provides a mosaic plot to visualize the association between two categorical variables

Usage

mosaic(formula,data,color=TRUE,labelat=c(),xlab=c(),ylab=c(),
                            magnification=1,equal=FALSE,inside=FALSE,ordered=FALSE) 

Arguments

formula

A standard R formula written as y~x, where y is the name of the variable playing the role of y and x is the name of the variable playing the role of x.

data

An optional argument giving the name of the data frame that contains x and y. If not specified, the function will use existing definitions in the parent environment.

color

TRUE or FALSE. If FALSE, plots are presented in greyscale. If TRUE, an intelligent color scheme is chosen to shade the plot.

labelat

a vector of factor levels of x to be labeled (in the case that you want only certain levels to be labeled)

xlab

Label of horizontal axis if you want something different that the name of the x variable

ylab

Label of vertical axis if you want something different that the name of the y variable

magnification

Magnification of the labels of the x variable. A number smaller than 1 shrinks everything. A number larger than 1 makes everything larger

equal

If FALSE, the bar widths are proportional to the frequency of the corresponding level. If TRUE, the bar widths are all equal (useful if there are many levels or some are extremely rare).

inside

If FALSE, labels are beneath the bars. If TRUE, labels are placed inside the bars and rotated (useful if the levels have long names)

ordered

If FALSE, bars are in alphabetical order. If TRUE, the ordering of the bars reflects the ordering of the factor levels.

Details

This function shows a mosaic plot to visualize the conditional distributions of y for each level of x, along with the marginal distribution of y to the right of the plot. The widths of the segmented bar charts are proportional to the frequency of each level of x. These plots are the same that appear using associate.

Author(s)

Adam Petrie

References

Introduction to Regression and Modeling

See Also

associate

Examples

  data(ACCOUNT)
	mosaic(Area.Classification~Purchase,data=ACCOUNT,color=TRUE)
	
	data(EX6.CLICK)
	#Default presentation:  not very useful
	mosaic(Click~DeviceModel,data=EX6.CLICK)  
	#Better presentation
	mosaic(Click~DeviceModel,data=EX6.CLICK,equal=TRUE,inside=TRUE,magnification=0.8)  
	 

[Package regclass version 1.6 Index]