[R] R hang-up using lm

kjetil@acelerate.com kjetil at acelerate.com
Wed Apr 28 01:19:59 CEST 2004


On 27 Apr 2004 at 16:46, Raubertas, Richard wrote:

> Within the last few weeks, someone else reported a similar
> problem when using the results of tapply in a call to rlm().
> Note that the result of tapply is a 1D array, and it appears
> there is a general problem with using such a thing on the
> RHS in formula-based modeling functions:
> 
> set.seed(3)
> yy <- rnorm(20)
> gg <- rep(1:10, 2)
> y <- tapply(yy, gg, median)
> x <- 1:10
> z <- lm(y ~ x)  # OK
> z <- lm(x ~ y)  # crashes R
> 
> (R 1.8.1 on Windows XP Pro)
> 

What exactly do you mean by "crashes R"

Doing this in R1.9.0, windows XP pro, there is no indication of 
problems.

Kjetil Halvorsen

> Rich Raubertas
> Merck & Co.
> 
> > -----Original Message-----
> > From: r-help-bounces at stat.math.ethz.ch 
> > [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of 
> > Jonathan Williams
> > Sent: Tuesday, April 27, 2004 1:17 PM
> > To: Ethz. Ch
> > Subject: [R] R hang-up using lm
> > 
> > 
> > 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
> > 
> > ______________________________________________
> > R-help at stat.math.ethz.ch mailing list
> > https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide! 
> > http://www.R-project.org/posting-guide.html
> > 
> > 
> 
> 
> ----------------------------------------------------------------------
> -------- Notice:  This e-mail message, together with any
> attachments,...{{dropped}}
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html




More information about the R-help mailing list