[R] R hang-up using lm

Jonathan Williams jonathan.williams at pharmacology.oxford.ac.uk
Tue Apr 27 19:17:13 CEST 2004


Dear R-helpers,
I have found a slightly annoying problem when trying to
plot lines on graphs. I first created my data using
tapply, thus:-
y1=as.vector(fit1$coef$random$id)
x1=tapply(o1,id,median,na.rm=T)
x2=tapply(o2,id,median,na.rm=T)

#then I plot the data, thus:-
plot(x1[x2==0],y[x2==0])
#if I now try to fit the linear regression, R 'hangs up'
abline(lm(y[x2==0]~x1[x2==0]),lty='solid')
#but, curiously, the problem does not occur if I plot the lowess line
lines(lowess(y[x2==0]~x1[x2==0]))

I can also avoid the problem by coercing x1 and x2 to be vectors.
So, I don't need help to solve the problem. But, it seems an odd
problem since it affects one plotting method, but not the other, 
and it actually causes R to crash.

Jonathan Williams
OPTIMA
Radcliffe Infirmary
Woodstock Road
OXFORD OX2 6HE
Tel +1865 (2)24356




More information about the R-help mailing list