Re: [R] clicking on plot and recording XY coords

From: jim holtman <jholtman_at_gmail.com>
Date: Sat, 21 Jun 2008 08:05:14 -0400

Is this something like you want? I assume you could also create a dialog box:

number.clicks<-4
my.coords<-NULL

for (i in 1:number.clicks)
 {

     plot(0,0, type="n")
     seg1<-arrows(-0.5,-1,0.5,0, col=1)
     seg2<-arrows(0,-1,-0.3,0.3, col=2)
     seg3<-arrows(0.2,-0.7,-0.5,0, col=4)
     if (readline("Acquire Points? (y/n)") == "y"){
         coord<-locator(1, type="p")
         my.coords<-rbind(my.coords, cbind(x=coord$x, y=coord$y))
     }

 }

my.coords

On Sat, Jun 21, 2008 at 12:17 AM, milton ruser <milton.ruser_at_gmail.com> wrote:
> Jim,
>
> In fact, if I click "stop" the for() looping and stop, and I need to
> continue on the for().
> By other side, is there a way of I ask for the user "acquire point" (with a
> dialog box with Yes or No options), and if the user anwer Yes I collect the
> points, otherwise I go for the next step of for() looping?
>
> sorry for do it so trouble.
> Kind regards
>
>
> miltinho
>
>
> On 6/21/08, jim holtman <jholtman_at_gmail.com> wrote:
>>
>> I am not sure how you would record a NULL. I assume that if you click
>> 'stop', then the result returned is a NULL and you can test for that.
>> Once you start collecting points, you should not have a NULL in the
>> series.
>>
>> On Fri, Jun 20, 2008 at 11:56 PM, milton ruser <milton.ruser_at_gmail.com>
>> wrote:
>> > Thanks Jim.
>> >
>> > I included your suggestion on the script and run fine.
>> > But how can I skip (record X and Y as NULL) on some steps?
>> > On this example it donīt occour, but when working with real data I will
>> > need
>> > bypass some acquisitions. Is there a way of do it on a for() looping? I
>> > noticed that if I click on right button of mouse the locator() ask for
>> > continue or stop. But some times I just want to record NULL for the
>> > position.
>> >
>> > Thanks a lot,
>> >
>> > Miltinho
>> > ============
>> >
>> > number.clicks<-4
>> > my.coords<-NULL
>> >
>> > for (i in 1:number.clicks)
>> > {
>> > plot(0,0, type="n")
>> > seg1<-arrows(-0.5,-1,0.5,0, col=1)
>> > seg2<-arrows(0,-1,-0.3,0.3, col=2)
>> > seg3<-arrows(0.2,-0.7,-0.5,0, col=4)
>> >
>> > coord<-locator(1, type="p")
>> > my.coords<-rbind(my.coords, cbind(x=coord$x, y=coord$y))
>> > }
>> >
>> > my.coords
>> >
>> >
>>
>>
>>
>> --
>> Jim Holtman
>> Cincinnati, OH
>> +1 513 646 9390
>>
>> What is the problem you are trying to solve?
>
>

-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?

______________________________________________
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.
Received on Sat 21 Jun 2008 - 12:09:24 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 21 Jun 2008 - 12:30:57 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive