Does anybody know how to adding colors to data points in scatter plot in R?
I have the following R data frame -
Voter_Name, Education_years, Income, Registered
Ricky, 18, 4, Y
Lisa, 20, 34000, N
Jon, 10, 35000, Y
...
I am doing a scatter plot in R for those data points - Income vs.
: zaterdag 23 mei 2009 7:18
Aan: r-help@r-project.org
Onderwerp: [R] how to adding colors to data points in scatter plot in R?
Does anybody know how to adding colors to data points in scatter plot in
R?
I have the following R data frame -
Voter_Name, Education_years, Income, Registered Ricky, 18
Simply use the col paramater, with a factor to index the colors.
Example:
# generate some data
x - rnom(100)
y - rnorm(x)
z - as.factor(rbinom(x,1,0.5))
# plot
plot(x,y, col=c('red','blue')[z])
HTH,
Matthieu
__
R-help@r-project.org mailing list
3 matches
Mail list logo