My guess is that 

> class(data[,3]) 

gives "factor" as the result, try casting to character if so. 

-----Original Message-----
From: [email protected] [mailto:[email protected]] On 
Behalf Of Vivek Ayer
Sent: Friday, July 24, 2009 1:24 PM
To: [email protected]
Subject: [R] Colors column don't give correct color with plot()

Hey guys,

I'm having trouble getting the correct colors, when they are read from
a csv file. Here's an example:

1 1 black
1 2 green
1 3 green
1 4 black
1 5 peachpuff

Call it blah.csv. Then I ran:

data <- read.csv("blah.csv",header=FALSE,sep="")

and then to plot the data, I ran:

plot(data[,1],data[,2],col=data[,3])

But the output reports a vertical line with colors:

black
red
red
black
green

going up. Is this a bug in R? If so, could someone fix it?

Thanks,
Vivek

______________________________________________
[email protected] 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.

______________________________________________
[email protected] 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.

Reply via email to