Michael
2012-Aug-31 21:09 UTC
[R] how to find the index of points selected from a scatter plot?
Hi all, I am using "locator" to select the points from a scatter plot... This is all fine. But the problem is that the locator only returns the axis values of the selected points. Instead, I would like to get the index of these select points... The axis values are real-values so it's a bit hard for me to directly reverse-engineer the index nubmers.. How to do that? Thank you! [[alternative HTML version deleted]]
Bert Gunter
2012-Aug-31 23:03 UTC
[R] how to find the index of points selected from a scatter plot?
?which ## as in ix <- which(x==values) -- Bert On Fri, Aug 31, 2012 at 2:09 PM, Michael <comtech.usa@gmail.com> wrote:> Hi all, > > I am using "locator" to select the points from a scatter plot... > > This is all fine. > > But the problem is that the locator only returns the axis values of the > selected points. > > Instead, I would like to get the index of these select points... > > The axis values are real-values so it's a bit hard for me to directly > reverse-engineer the index nubmers.. > > How to do that? > > Thank you! > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@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. >-- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm [[alternative HTML version deleted]]
Peter Ehlers
2012-Aug-31 23:10 UTC
[R] how to find the index of points selected from a scatter plot?
On 2012-08-31 16:03, Bert Gunter wrote:> ?which ## > as in ix <- which(x==values) > > -- BertOr maybe ?identify. Peter Ehlers> > On Fri, Aug 31, 2012 at 2:09 PM, Michael <comtech.usa at gmail.com> wrote: > >> Hi all, >> >> I am using "locator" to select the points from a scatter plot... >> >> This is all fine. >> >> But the problem is that the locator only returns the axis values of the >> selected points. >> >> Instead, I would like to get the index of these select points... >> >> The axis values are real-values so it's a bit hard for me to directly >> reverse-engineer the index nubmers.. >> >> How to do that? >> >> Thank you! >> >> [[alternative HTML version deleted]] >> >> ______________________________________________ >> 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. >> > > >
Greg Snow
2012-Sep-03 19:07 UTC
[R] how to find the index of points selected from a scatter plot?
I would be very surprised if the x value from locator matched the x value in the data to the precision needed by ==, and what if 2 points have the same x-value but different y-values, you would need to also check the y's. With appropriate rounding this would work, but would just be reinventing the identify function (as Peter pointed out). So if you are happy to reinvent wheels for learning purposes then locator, which, and rounding (or min) could teach a lot. If the simplest most straight forward solution is sought, then use identify instead of locator. On Fri, Aug 31, 2012 at 5:03 PM, Bert Gunter <gunter.berton at gene.com> wrote:> ?which ## > as in ix <- which(x==values) > > -- Bert > > On Fri, Aug 31, 2012 at 2:09 PM, Michael <comtech.usa at gmail.com> wrote: > >> Hi all, >> >> I am using "locator" to select the points from a scatter plot... >> >> This is all fine. >> >> But the problem is that the locator only returns the axis values of the >> selected points. >> >> Instead, I would like to get the index of these select points... >> >> The axis values are real-values so it's a bit hard for me to directly >> reverse-engineer the index nubmers.. >> >> How to do that? >> >> Thank you! >> >> [[alternative HTML version deleted]] >> >> ______________________________________________ >> 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. >> > > > > -- > > Bert Gunter > Genentech Nonclinical Biostatistics > > Internal Contact Info: > Phone: 467-7374 > Website: > http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm > > [[alternative HTML version deleted]] > > ______________________________________________ > 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.-- Gregory (Greg) L. Snow Ph.D. 538280 at gmail.com