Utility Functions to Identify and Mark Extreme Points in a 2D Plot.
This function is called by several graphical functions in the
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.
showLabels(x, y, labels=NULL, id.method="identify", id.n = length(x), id.cex=1, id.col=palette(), ...)
- Plotted horizontal coordinates.
- Plotted vertical coordinates.
- Plotting labels. If
NULL, case numbers will be used. If labels are long, the
abbreviatefunction can be used to shorten them.
- How points are to be identified. See Details below.
- Number of points to be identified. If set to zero, no points are identified.
- Controls the size of the plotted labels. The default is
- Controls the color of the plotted labels.
- additional arguments passed to
id.method determine how the points
to be identified are selected. For the default value of
identify function is used to identify points
interactively using the mouse. Up to
id.n points can be identified,
id.n=0, which is the default in many functions in the
package, then no point identification is done.
Automatic point identification can be done depending on the value of the
id.method = "x"select points according to their value of
abs(x - mean(x))
id.method = "y"select points according to their value of
abs(y - mean(y))
id.method = "mahal"Treat
(x, y)as if it were a bivariate sample, and select cases according to their Mahalanobis distance from
id.methodcan be a vector of the same length as
xconsisting of values to determine the points to be labeled. For example, for a linear model
id.method=cooks.distance(m), id.n=4will label the points corresponding to the four largest values of Cook's distance, or
id.method = abs(residuals(m, type="pearson")), id.n=2would label the two observations corresponding to the largest absolute Pearson residuals.
id.methodcan be a vector of case numbers or case-labels, in which case those cases will be labeled, as long as
id.nis greater than zero.
id.methodargument can be 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.
- A utility function used for its side-effect of drawing labels on a plot.
Although intended for use with other functions in the
carpackage, this function can be used directly.
Fox, J. and Weisberg, S. (2011) An R Companion to Applied Regression, Second Edition, Sage. Weisberg, S. (2005) Applied Linear Regression, Third Edition, Wiley.
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))