[R] Colors column don't give correct color with plot()

Vivek Ayer vivek.ayer at gmail.com
Fri Jul 24 20:41:44 CEST 2009


Problem solved! Thanks! I'm still a noob at learning R, so eventually
I'll figure out all these different datatypes.

Vivek

On Fri, Jul 24, 2009 at 11:35 AM, Henrique Dallazuanna<wwwhsd at gmail.com> wrote:
> Isn't a bug,
>
> try this
>
> plot(d[,1],d[,2],col=as.character(d[,3]))
>
> its because d[,3] is a factor.
>
> Or in read.csv:
>
> d <- read.csv("blah.csv",header=FALSE,sep="", stringsAsFactor = FALSE)
>
> On Fri, Jul 24, 2009 at 3:23 PM, Vivek Ayer <vivek.ayer at gmail.com> wrote:
>>
>> 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
>>
>> ______________________________________________
>> R-help at r-project.org 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.
>
>
>
> --
> Henrique Dallazuanna
> Curitiba-Paraná-Brasil
> 25° 25' 40" S 49° 16' 22" O
>




More information about the R-help mailing list