Re: [R] (no subject)

From: Charilaos Skiadas <>
Date: Sun, 23 Mar 2008 19:51:57 -0400

As you have not given us a reproducible example (namely we don't really know what "test" is), there are likely better ways to do this than what I am about to suggest, and you can find examples in the relevant plot functions likely, but I think what you want can be achieved using ifelse:

  plot(test, col = ifelse(test[,1]<8 , "steelblue2" ,"wheat2") )

Haris Skiadas
Department of Mathematics and Computer Science Hanover College

On Mar 23, 2008, at 7:06 PM, Donna Tucker wrote:

> Is there any way to use more than one color or shape in the same
> plot. I would like to make the points different colors for various
> levels of a variable. I have tried a simple 'if' statement in the
> plot command, but I get an error message. Here is what I have
> tried and the error message I get: > plot(test, if(test[,1]<8)
> col="steelblue2" else col="wheat2")Error in xy.coords(x, y, xlabel,
> ylabel, log) : 'x' and 'y' lengths differIn addition: Warning
> message:In if (test[, 1] < 8) col = "steelblue2" else col =
> "wheat2" : the condition has length > 1 and only the first element
> will be usedI know 'x' and 'y' lenghths do NOT differ. If I just
> do plot(test), it works perfectly. Is there any way to this?
> Thanks,Donna mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Sun 23 Mar 2008 - 23:56:29 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 Mon 24 Mar 2008 - 00:30:24 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive