Re: [R] Graphing help revisited

From: Greg Snow <Greg.Snow_at_imail.org>
Date: Thu, 05 Jun 2008 11:48:24 -0600

Does this do what you want?

Bill <- data.frame(A= c(1,1,1,2,3,4,5,6,6,7),

        B=c(5,5,6,7,7,7,8,9,10,11),
        group=rep(1:2, each=5) )

with(Bill, plot(A,B, pch=group) )

mns <- with(Bill, tapply(B, group, mean))

tmp <- par('usr') # or range(Bill$A)
med <- with(Bill, mean( c(max(A[group==1]), min(A[group==2]) ) ) )

lines( c(tmp[1], med, tmp[2]), mns[ c(1,2,2) ], type='s' )

Hope this helps,

--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow_at_imail.org
(801) 408-8111




> -----Original Message-----
> From: r-help-bounces_at_r-project.org
> [mailto:r-help-bounces_at_r-project.org] On Behalf Of William Pepe
> Sent: Thursday, June 05, 2008 11:19 AM
> To: r-help_at_r-project.org
> Subject: [R] Graphing help revisited
>
>
> Sorry, my last post came out unreadable. I'll try again. Here
> is the data. Think of them as transposed columns. A:
> 1,1,1,2,3,4,5,6,6, 7B: 5,5,6,7,7,7,8,9,10,11 Split the data
> into two groups, each of size 5, and make a scatterplot.
> Bill<-read.table('something here')
> attach(Bill)Bill.s<-split(Bill, rep(1:2,
> each=5))plot(A,B,col='black') Group
> 1:A:1,1,1,2,3B:5,5,6,7,7Group 2:A:4,5,6,6,7B:7,8,9,10,11 For
> each group, find the mean of B.... Group 1:mean=6. Group 2:
> mean=9. On the scatterplot of A vs. B: For group 1, need
> horizontal line at the mean of 6. It should only cover the
> points in group 1.For group 2, need horizontal line at the
> mean of 9. Again, should only cover the points in group 2.
> The endpoints of the different horizontal lines must connect.
>
> I rather do this where I can change the size of the group as
> well. Any help is greatly appreciated. Bill
> _________________________________________________________________
> Search that pays you back! Introducing Live Search cashback.
>
> rchpaysyouback
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>
______________________________________________ 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 Thu 05 Jun 2008 - 19:33: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 Thu 05 Jun 2008 - 20:32:34 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