[R] bug in dummy.coef?

Alexandra Kuznetsova alku at dtu.dk
Fri Oct 25 08:24:56 CEST 2013

Thank  you for the reply!
I need to use it in the package for constructing the contrast matrices.
 Renaming a variable like y2 <- y^2 will not be a solution for me...
Will try to look whether the  function dummy.coef can be modified to work this issue.

With best regards,

-----Original Message-----
From: David Winsemius [mailto:dwinsemius at comcast.net] 
Sent: 25. oktober 2013 00:58
To: Alexandra Kuznetsova
Cc: r-help at r-project.org
Subject: Re: [R] bug in dummy.coef?

On Oct 24, 2013, at 1:51 AM, Alexandra Kuznetsova wrote:

> Dear all,
> Running the following code produces an error in dummy.coef. I guess it might be a bug..
>> ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)
>> trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)
>> group <- gl(2, 10, 20, labels = c("Ctl","Trt")) weight <- c(ctl, trt) 
>> x <- rnorm(length(weight))
>> lm.D9 <- lm(weight ~ group + x + I(x^2))
>> dummy.coef(lm.D9)
> Error in rep.int(xl[[i]][1L], nl) : invalid 'times' value

As Rolf Turner pointed out the help page says there are limitations to that function and its only desiged for specific purposes. What are you trying to accomplish?


David Winsemius
Alameda, CA, USA

More information about the R-help mailing list