[R] problem using identify() after plot()

Uwe Ligges ligges at statistik.tu-dortmund.de
Sat Jan 31 17:24:09 CET 2009



Christopher W. Ryan wrote:
> I can't seem to use the point-and-click identify() function properly.
> I'm running R 2.5.1 (I know, I need to get around to upgrading) under
> Win XP. The problem is, when I click on a point on the graph, I get an
> error, "no point within 0.25 inches." But in some areas, I can click
> where there is no visible point anywhere close, and an identify() label
> will pop up. The troublesome code is shown below.  I've posted an
> example graph here:
> 
> http://bingweb.binghamton.edu/~cryan/junkidentify2.pdf
> 
> I'd be grateful if anyone could take a look at it. The text() labels are
> in red, and the results of pointing-and-clicking are shown in black.
> Notice point 4, for example: near the origin in black, but upper center
> in red (which is where the real data point should be: point 4 is (11,16)

Everything as expected given your call (you plot numbers 1:46 at 
locations x=1:46 and y=1:46 dependend on your clicks). What you probably 
want is:

identify(V2, mean.barr, rownames(temp))

Uwe Ligges



> Any chance all the NA's are the problem?
> 
> plot(V2,mean.barr, type="n")
> text(V2, mean.barr, label=rownames(temp), col="red")
> identify(rownames(temp))
> # here's the gist of the data
> str(temp)
> summary(temp)
> rownames(temp)
> temp
> 
>    mean.barr V2
> 1         NA  6
> 2         NA  1
> 3       12.5  6
> 4       16.0 11
> 5       11.0  4
> 6       12.0  0
> 7         NA  4
> 8         NA  5
> 9         NA  2
> 10        NA  3
> 11      16.5 11
> 12      14.5  8
> 13        NA  1
> 14       7.5  4
> 15      12.5  1
> 16      20.0  0
> 17        NA 10
> 18      17.0 11
> 19        NA  0
> 20       8.5  5
> 21      10.5  8
> 22      12.0  5
> 23       5.0  1
> 24       8.5  7
> 25        NA 19
> 26      12.0  0
> 27        NA  2
> 28        NA  0
> 29      12.5  5
> 30      18.0 10
> 31      16.5 20
> 32      16.5 19
> 33       9.0  4
> 34       9.5  4
> 35       7.0  1
> 36       8.0  4
> 37       8.5 13
> 38      18.5 13
> 39       9.0  9
> 40      11.0  1
> 41       4.0  7
> 42      11.5 26
> 43       3.5 12
> 44       8.5 12
> 45      10.0 15
> 46      11.0  5
> 
> Thanks
> 
> --Chris




More information about the R-help mailing list