| highlight {NCStats} | R Documentation |
Labels a list of points on a two-dimensional plot.
highlight(x, ...)
## Default S3 method:
highlight(x, y, lbls = NULL,
pts = NULL, col = "red", cex = 1.25, pos = NULL, ...)
## S3 method for class 'formula'
highlight(x, data = NULL, lbls = NULL,
pts = NULL, col = "red", cex = 1.25, pos = NULL, ...)
x |
The vector of x coordinates or a formula of the
form |
y |
The vector of y coordinates. |
data |
The data frame from which the formula should be evaluated. |
lbls |
The name of the variable in |
pts |
The vector of row numbers corresponding to the
points to highlight. If left as |
col |
A numeric or string indicating the color to use when labeling the points. |
cex |
A numeric characther expansion number for the point labels. |
pos |
A numeric indicating where to place the labels
(see |
... |
Other arguments to be passed to
|
A two dimensional plot must be active and the x
and y vectors must correspond to the x- and y-axes
of the plot or x must correspond to the formula
used to produce the plot.
None, but an active graphic is modified.
df <- data.frame(x=runif(10),y=runif(10),grp=factor(rep(c("Yes","No"),each=5)))
plot(y~x,data=df)
# highlight the first and second points with default positioning using the formula notation
highlight(y~x,data=df,lbls=grp,pts=c(1,2))
# highlight the third and fourth points with user-chosen positioning
highlight(y~x,data=df,lbls=grp,pts=c(3,4),pos=c(1,2),col="blue")
# highlight the fifth and sixth points illustrating lack of data= argument
with(df,highlight(y~x,lbls=grp,pts=c(5,6),col="orange"))
# highlight the seventh and eighth points illustrating no use of formula
with(df,highlight(x,y,lbls=grp,pts=c(7,8),col="yellow"))
# highlight the ninth and tenth points with numeric labeling
highlight(y~x,data=df,pts=c(9,10),col="green")
# label all points with their row numbers
plot(y~x,data=df)
highlight(y~x,data=df)