[R] Plot where points are treatment letter

David Winsemius dwinsemius at comcast.net
Tue Feb 8 23:13:37 CET 2011


On Feb 8, 2011, at 3:42 PM, Schatzi wrote:

>
> I would like to create a plot of y vs x with different treatments  
> where the
> points are actually the letter of the treatment. Here is the code:
>
> A<-as.matrix(rnorm(10,10))
> B<-as.matrix(rnorm(10,9.5))
> C<-as.matrix(rnorm(10,10.5))
> Y<-as.matrix(rnorm(30,13))
> X<-rbind(A,B,C)
> nA<-matrix("A",10,1)
> nB<-matrix("B",10,1)
> nC<-matrix("C",10,1)
> TRT<-rbind(nA,nB,nC)
>
> plot(X,Y)
> xyplot(Y~X,groups = TRT)


?plot
?xyplot

 > plot(X,Y, pch=LETTERS[1:3], col=1:3)
 > xyplot(Y~X,groups = TRT, pch=LETTERS[1:3], col=1:3)

>
> The last plot colors the points by treatment, but it uses points,  
> not the
> letter for each treatment. Does anyone know how to do this? It seems  
> simple
> enough and I'm sure it is very easy, I just cannot figure it out nor  
> have I
> found the code. Thank you.
>
>
> -- 
> View this message in context: http://r.789695.n4.nabble.com/Plot-where-points-are-treatment-letter-tp3276751p3276751.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list