[R] plot and subsets

Martin Maechler maechler at stat.math.ethz.ch
Tue Nov 27 19:17:12 CET 2001

>>>>> "Erich" == Erich Neuwirth <erich.neuwirth at univie.ac.at> writes:

    Erich> when i need to plot the same variables (size and
    Erich> weight e.g.)  for different groups (male and female)
    Erich> in one scatterplot, i seem have to use plot() for the
    Erich> first group and points() for the second group.

    Erich> is there a plotting function somewhere which would
    Erich> use a factor variable automatically to represent the
    Erich> different groups by different symbols and/or colors.

    Erich> i know it is not too difficult to write such a
    Erich> function for oneself, the question is if this should
    Erich> be part of a standard toolkit already.

    Erich> or am i just plainly overlooking something which is
    Erich> already there.
yes, indeed you are :
plot() itself

    Erich> by(data,factor,plot)

    Erich> could be a "role model".  and this seems not to work.

Something like

  plot( <data>,  pch = as.integer(factor),
		 col = as.integer(factor))

 {which I think does not work in S-plus}

  Please do not "reply" to an R-help message when you want to
  post something new to the list.  Those of us who use smart
  mail readers with `threading' are out-smarted by that.

Martin Maechler <maechler at stat.math.ethz.ch>	http://stat.ethz.ch/~maechler/
Seminar fuer Statistik, ETH-Zentrum  LEO D10	Leonhardstr. 27
ETH (Federal Inst. Technology)	8092 Zurich	SWITZERLAND
phone: x-41-1-632-3408		fax: ...-1228			<><
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