[R] how exactly does 'identify' work?

Duncan Murdoch murdoch.duncan at gmail.com
Thu Nov 18 20:02:31 CET 2010

On 18/11/2010 1:50 PM, casperyc wrote:
> Hi,
> I think the problem is
> 1 - when a linear model is fitted, ploting the qqnorm( test.lm$ res )
> we dont 'know' what values are actually being used on the y-axis; and
> how do we refer to the ‘Index’ on the x-axis??
>       therefore, i dont know how to refer to the x and y coordinates in the
> identify function

You could look at qqnorm.default to figure those things out, but it is 
probably difficult to do.  You'd be better off using locator() to find 
the coordinates of a mouse click, and plotting the label using text().

For a simple example,

x <- rnorm(100, mean=10, sd=2)
repeat {
   pt <- locator(1)
   if (!length(pt$x)) break
   text(pt, labels=which.min( abs(x - pt$y) ) )

Duncan Murdoch

> 2 - i have tried using the stdres function in the MASS library, to extract
> the standardised
> residuals and plot them manully, ( using the plot ) function.
>       this way, the problem is we have to SORT the residuals first in
> increasing order to reproduce the same qqnorm plot, in that case, 'identify'
> function works, however, that CHANGES the order, i.e. it wont return the
> original A:Z ( row.names ) label.

More information about the R-help mailing list