[R] plot and subsets
Ben Bolker
ben at zoo.ufl.edu
Tue Nov 27 19:26:23 CET 2001
e.g.: to plot with colors 1 and 2 (easiest) and plotting characters 1 and
16:
x <- runif(10)
y <- runif(10)
z <- factor(sample(1:2,size=10,replace=TRUE))
plot(x,y,col=as.numeric(z),pch=c(1,16)[as.numeric(z)])
On Tue, 27 Nov 2001, Erich Neuwirth wrote:
> when i need to plot the same variables
> (size and weight e.g.)
> for different groups (male and female)
> in one scatterplot,
> i seem have to use plot() for the first group and
> points() for the second group.
>
> is there a plotting function somewhere which would use a factor variable
> automatically to represent the different groups
> by different symbols and/or colors.
>
> i know it is not too difficult
> to write such a function for oneself,
> the question is if this should be part of a standard toolkit already.
>
> or am i just plainly overlooking something which is already there.
>
>
> by(data,factor,plot)
>
> could be a "role model".
> and this seems not to work.
>
>
>
>
> --
> Erich Neuwirth, Computer Supported Didactics Working Group
> Visit our SunSITE at http://sunsite.univie.ac.at
> Phone: +43-1-4277-38624 Fax: +43-1-4277-9386
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>
--
318 Carr Hall bolker at zoo.ufl.edu
Zoology Department, University of Florida http://www.zoo.ufl.edu/bolker
Box 118525 (ph) 352-392-5697
Gainesville, FL 32611-8525 (fax) 352-392-3704
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list