[R] how exactly does 'identify' work?
Greg Snow
Greg.Snow at imail.org
Thu Nov 18 17:57:57 CET 2010
I think that your problem comes from a misunderstanding.
The general rule is that you give the plot command 2 vectors, x and y (though you can give it the vectors separately, or together in a list or matrix). If you give plot only a single vector then it will use this as the y vector and use the sequence of integers from 1 to the length of y as the x variable. Now in your example that matches your x exactly.
In your working examples you either give the function both x and y, or only y and the generated sequence for x happens to match your x for this specific example, but not in general. For your non-working examples you give only the x variable, which is then used as the y variable and the sequence is generated for x, so it will only identify points along the diagonal. It does not know where to find your y variable.
The fix, always give both x and y (the fact that your examples worked with only y is due to your specific example, not anything general).
--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
801.408.8111
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of casperyc
> Sent: Tuesday, November 16, 2010 5:03 PM
> To: r-help at r-project.org
> Subject: [R] how exactly does 'identify' work?
>
>
> Hi all,
>
> #########################################
> test=data.frame(x=1:26,y=-23.5+0.45*(1:26)+rnorm(26))
> rownames(test)=LETTERS[1:26]
> attach(test)
> #test
> test.lm=lm(y~x)
>
> plot(test.lm,2)
> identify(test.lm$res,,row.names(test))
> # not working
>
> plot(x,y)
> identify(x,y,row.names(test))
> # works fine
> identify(y,,row.names(test))
> # works fine
> identify(x,,row.names(test))
> # not working
> identify(y,,y)
> # works
> identify(x,,y)
> # not working
>
> #####################################
>
> My guess is that identify take the object 'x' ( the first argument ) is
> the
> thing that on the y axis.
>
> However, i have tried many many ways
> trying to get the LETTERS to be identified in the QQ-plot
> (plot(test.lm,2))
> it never works.....
>
> I have even tried to extract the standardized residual using
> library(MASS),
> the 'stdres' function, and put it as the first argument in identify,
> still failed...
>
> Is there any means to achieve this?
>
> Thanks!
>
> casper
> --
> View this message in context: http://r.789695.n4.nabble.com/how-
> exactly-does-identify-work-tp3045953p3045953.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list