Skip to content

(no subject)

3 messages · Donna Tucker, Charilaos Skiadas, Jim Lemon

#
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:

            
#
Donna Tucker wrote:
Hi Donna,
What is happening is that you have passed two arguments to "plot" 
without naming them. The first one (test) is interpreted as the "x" 
coordinates, and the second one:

if(test[,1]<8) col="steelblue2" else col="wheat2"

finishes up as "steelblue2" if test[1,1] is less than 8 or "wheat2" if 
not. This is interpreted as the "y" coordinates. Unless you have only 
one element in test (and of course we can infer that you have more), 
those lengths will differ. What you can do is to specify that your 
second argument is meant to be a color vector like this:

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

Now of course I am assuming that "test" is a matrix or data frame with 
at least two columns. If it isn't, the above example will fall over and 
whinge.

 > How well do you know your celebrity gossip?

I'm sorry, but I can't help you at all with that.

Jim