[R] Graphing help revisited

Greg Snow Greg.Snow at imail.org
Thu Jun 5 19:48:24 CEST 2008


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.
>



More information about the R-help mailing list