[R] How to label certain values on a curve?
(Ted Harding)
Ted.Harding at wlandres.net
Wed Jun 6 23:25:17 CEST 2012
On the subject of identify() [perhaps I should change thread]:
'?identify' clearly states:
Value:
If 'pos' is 'FALSE', an integer vector containing the indices
of the identified points, in the order they were identified.
However, I find that the result is not in the order of identification,
but rather with the indices sorted in increasing order. Example:
set.seed(54321); x<-rnorm(100); y<-rnorm(100)
plot(x,y)
Now go anticlockwise round the points which you judge to be
the vertices of the convex hull of this plot, using
ix <- identify(x,y,plot=FALSE,pos=FALSE)
I see 9 such points, and I start with the one with smallest y value,
going anticlockwise. The result is
ix
# [1] 8 15 17 21 25 44 63 94 99
and now:
lines(x[ix],y[ix])
while it joins the points, does not do so in the order in which they
were identified. Using
identify(x,y,plot=TRUE,pos=FALSE)
puts the indices as labels on the points, and the order of
identification (read off anticlockwise from the graph) is:
25 21 17 8 44 99 63 15 94
This is on R version 2.11.0 (2010-04-22), Debian Linux, X11.
Have things changed since then?
Ted.
On 06-Jun-2012 16:38:14 R. Michael Weylandt wrote:
> Take a look at the identify() function.
>
> Best,
> Michael
>
> On Wed, Jun 6, 2012 at 11:23 AM, Wendy Han <wendyhan08 at gmail.com> wrote:
>> Hi all,
>>
>> I have drawn a curve in R and observed some interesting values, I wonder if
>> there is any method to mark certain values on this curve, so that I
>> can manually choose the point and know the exact value of this point
>> simultaneously? I appreciate your suggestions and advice!
>>
>> Thanks a lot!
>> Wendy
-------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at wlandres.net>
Date: 06-Jun-2012 Time: 22:25:14
This message was sent by XFMail
More information about the R-help
mailing list