[R] Change color of plot points based on values of a variable

Dieter Menne dieter.menne at menne-biomed.de
Wed Oct 1 12:09:25 CEST 2008

Josip Dasovic <jjd9 <at> sfu.ca> writes:

> I have run a logistic regression, used Gelman et al.'s car package to 
>> simulate the parameter estimates of

"car" is by John Fox. You meant "arm".

> I would like the points from 1-24, and 976-1000 to
be one color (the default color is
> fine), and the points 25-975 to be a different color.

Please check your code in a fresh window before you submit it. There were 
7 errors in your code that I almost gave up, and I am sure other people had 
the same problem.


fit.1<-glm(y~x, family=binomial(link="logit"))
sim.fit.1<-sim(fit.1, 1000)  
plotdt =sort(invlogit(sim.fit.1$beta[,1]+sim.fit.1$beta[,2]*mean(x)))
col = rep("black",length(plotdt))
col[1:24] = "red"

More information about the R-help mailing list