Re: [R] Plotting Ranges as Vertical Lines

From: Uwe Ligges <ligges_at_statistik.uni-dortmund.de>
Date: Fri 27 May 2005 - 02:32:05 EST

Some example code using segments():

  x <- 1:10
  low <- rnorm(10)
  high <- rnorm(10)
  plot(x, low, ylim = range(c(low, high)), type="n")   segments(x, low, x, high)

Uwe Ligges

Bret Collier wrote:

> R Users,
> I have not been able to find anything close to what I want searching
> R-help and I am hoping someone could point me in the right direction.
>
> The data consists of differences in length of individual salamanders
> collected at time of initial capture and last recapture (excerpt below).
> What I am trying to do is plot a vertical line for each individual (ID)
> representing the change in size between initial capture (CAPTURESVL) and
> last recapture (RECAPSVL) (the range of sizes would be on the y-axis),
> hence vertical line length would be equal to GROWTH (which can be + or
> -). I would like to make this plot over the time between recaptures
> (MONTHELAPSED) which would be on the x-axis.
>
> ID CAPMONTH CAPTURESVL CAPTUREMASSGR RECAPMONTH RECAPSVL
> RECAPMASSGR GROWTH MASSGR MONTHELAPSED
> 1 SJC8 3 21 0.1 11 22
> 0.2 1 0.1 8
> 2 SJC9 3 33 0.7 13 35
> 0.9 2 0.2 10
> 3 SJC10 3 19 0.5 9 20
> 0.2 1 -0.3 6
> 4 SJC11 4 36 1.1 13 41
> 1.5 5 0.4 9
> 5 SJC12 4 19 0.1 15 28
> 0.4 9 0.3 11
> 6 SJC17 6 24 0.3 11 26
> 0.4 2 0.1 5
> 7 SJC18 6 43 1.1 24 43
> 1.8 0 0.7 18
> 8 SJC23 7 16 0.1 15 20
> 0.1 4 0.0 8
> 9 SJC24 7 22 0.5 22 40
> 1.9 18 1.4 15
> 10 SJC25 8 23 0.4 15 27
> 0.6 4 0.2 7
> 11 SJC32 9 37 1.1 16 38
> 1.5 1 0.4 7
> 12 SJC34 9 31 0.8 12 33
> 1.1 2 0.3 3
> 13 SJC35 9 19 0.2 14 23
> 0.3 4 0.1 5
> 14 SJC53 11 41 1.2 12 40
> 1.4 -1 0.2 1
> 15 SJC55 11 41 1.3 12 40
> 1.7 -1 0.4 1
> 16 SJC60 11 39 1.5 22 41
> 1.8 2 0.3 11
> 17 SJC65 12 41 1.5 23 44
> 1.8 3 0.3 11
>
> I am stuck on how to 1) create the vertical segments and 2) link them
> to x-axis values for MONTHELAPSED? I would have provided some example
> code, except I have not been able to figure out how to approach this
> yet. Since I am probably not looking in the right place, could someone
> point me in the right direction or towards some example figure code/help
> files that I must have missed in my searching?
>
> Thanks,
> Bret
> TX A&M
>
> platform i386-pc-mingw32
> arch i386
> os mingw32
> system i386, mingw32
> status
> major 2
> minor 0.1
> year 2004
> month 11
> day 15
> language R
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Fri May 27 02:41:51 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:32:07 EST