Re: [R] adding lines to stripchart

From: Chuck Cleland <ccleland_at_optonline.net>
Date: Mon, 25 Jun 2007 04:28:27 -0400

James Root wrote:
> I have two points of collection across 20 subjects (pre and post for each),
> so 20 pairs of data points. I would like to plot the actual raw data points
> for each subject for both pre and post and connect lines between these two
> points (20 in all) to depict real change between the two timepoints.
>
> I have tried using stripchart which adequately plots the two lines of
> subject data points. Attempting to use segments however has been
> difficult. It seems that the segments command gives too many coordiate
> points - so where segments has:
>
> x0, y0, x1, y1
>
> I really only have two coordinates for each point -
>
> pre to post
>
> I am sure that I am misusing the command but not sure if I should continue
> to try with segments or if there is another command that would be more
> appropriate.
>
> As always, thanks for any help.

  Here is how you might use segments() and stripchart():

df <- data.frame(pre = runif(20), post = runif(20))

stripchart(x = list(df$pre, df$post), vertical=TRUE, group.names=c("Pre","Post"))

for(i in 1:nrow(df)){segments(1, df$pre[i], 2, df$post[i])}

> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help_at_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
> and provide commented, minimal, self-contained, reproducible code.

-- 
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894

______________________________________________
R-help_at_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
and provide commented, minimal, self-contained, reproducible code.
Received on Mon 25 Jun 2007 - 08:33:10 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 Mon 25 Jun 2007 - 10:32:29 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.