showLabels: Utility Functions to Identify and Mark Extreme Points in a 2D...

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/showLabels.R

Description

This function is called by several graphical functions in the car package to mark extreme points in a 2D plot. Although the user is unlikely to call this function directly, the documentation below applies to all these other functions.

Usage

1
2
3
showLabels(x, y, labels=NULL, id.method="identify",  
  id.n = length(x), id.cex=1, id.col=palette()[1], id.location="lr", ...)
     

Arguments

x

Plotted horizontal coordinates.

y

Plotted vertical coordinates.

labels

Plotting labels. If NULL, case numbers will be used. If labels are long, the substr or abbreviate function can be used to shorten them.

id.method

How points are to be identified. See Details below.

id.n

Number of points to be identified. If set to zero, no points are identified.

id.cex

Controls the size of the plotted labels. The default is 1.

id.col

Controls the color of the plotted labels.

id.location

Where should the label be drawn? The default is "lr" to draw the label to the left of the point for points in the right-half of the graph and to the right for points in the left-half. The other option is "ab" for above the point for points below the middle of the graph and above the point below the middle.

...

additional arguments passed to identify or to text.

Details

The argument id.method determine how the points to be identified are selected. For the default value of id.method="identify", the identify function is used to identify points interactively using the mouse. Up to id.n points can be identified, so if id.n=0, which is the default in many functions in the car package, then no point identification is done.

Automatic point identification can be done depending on the value of the argument id.method.

With showLabels, the id.method argument can be a list, so, for example id.method=list("x", "y") would label according to the horizontal and vertical axes variables.

Finally, if the axes in the graph are logged, the function uses logged-variables where appropriate.

Value

A utility function primarily used for its side-effect of drawing labels on a plot. Returns invisibly the labels of the selected points, or NULL if no points are selected. Although intended for use with other functions in the car package, this function can be used directly.

Author(s)

John Fox jfox@mcmaster.ca, Sanford Weisberg sandy@umn.edu

References

Fox, J. and Weisberg, S. (2011) An R Companion to Applied Regression, Second Edition, Sage.

Weisberg, S. (2014) Applied Linear Regression, Fourth Edition, Wiley.

See Also

avPlots, residualPlots, crPlots, leveragePlots

Examples

1
2
3
4
5
6
7
8
plot(income ~ education, Prestige)
with(Prestige, showLabels(education, income, 
     labels = rownames(Prestige), id.method=list("x", "y"), id.n=3))
m <- lm(income ~ education, Prestige)
plot(income ~ education, Prestige)
abline(m)
with(Prestige, showLabels(education, income, 
     labels=rownames(Prestige), id.method=abs(residuals(m)), id.n=4))

jonathon-love/car documentation built on May 19, 2019, 7:28 p.m.