[R-sig-ME] Why no "dataClasses" attribute at terms for lmer object

Ben Bolker bbolker at gmail.com
Mon Dec 16 14:50:09 CET 2013


On 13-12-15 08:51 PM, Luo, Dongwen wrote:
> Dear Sir,
> 
> 
> 
> I have written a package depends on lme4, in some of my functions
> need info about which term in the model is numeric (or factor) .
> Usually, we can get it by using
> 
> attr(terms(lmer), “dataClasses”)
> 
> However, now in lme4 this attribute is disappear, anyway I could
> find the info?
> 

  This workaround might help you in the short term, although there are
lots of situations where it will be fragile/won't work properly:

sapply(all.vars(formula(fm1)),function(x) class(model.frame(fm1)[[x]]))
##  Reaction      Days   Subject
## "numeric" "numeric"  "factor"

 (you can use fixed.only=TRUE in formula() if you want to exclude the
random effects variables from the list).

  In the medium/long term, we can look into what is going on here: I've
opened https://github.com/lme4/lme4/issues/160



> 
> 
> Best regards
> 
> 
> 
> Dongwen Luo Statistician T +64 6 351 8139 F +64 6 351 8032 E
> dongwen.luo at agresearch.co.nz <mailto:dongwen.luo at agresearch.co.nz>
> 
> Grasslands Research Centre Tennent Drive, Private Bag 11008,
> Palmerston North 4442, New Zealand T  +64 6 356 8019  F  +64 6 351
> 8032  www.agresearch.co.nz <http://www.agresearch.co.nz>
> 
> 
> 
> =======================================================================
>
> 
Attention: The information contained in this message and...{{dropped:10}}



More information about the R-sig-mixed-models mailing list