[R] lm() and factors appending

Peter Ehlers ehlers at ucalgary.ca
Wed Dec 30 21:40:04 CET 2009

Gee, so much excitement over such a little thing.
So how exactly would you prefer lm() to tell you
what levels of your factors are being taken as the
reference levels?

Post-processing, if necessary, would seem to be
pretty trivial.

If you want to re-run lm() on modified sets of
predictors, what's wrong with editing the lm(...)
command or using update()?

  -Peter Ehlers

Idgarad wrote:
> How for the love of god can I prevent the lm() function from padding on to
> my factor variables?
> I start out with 2 tables:
> Table1
> 123123
> 124351
> ...
> 626773
> Table2
> 1231,T,F
> 4521,F,T
> ...
> 3321,T,T
> Everything looks fine when I import the data.
> then we get a
> oh_crap <- lm(table1 ~ Count + IS_DEAD + IS_BURNING, table2)
> Magically when I look at my oh_crap coefficents they get turned into
> I get it that it finds them to be factors by how in the name of all that is
> holy do I prevent them from doing that crap since later after a stepwise
> removal I go into one of the models grab what coefficents were kept
> (IS_BURNINGTTRUE now) and read future regressors from the original table
> which read IS_BURNING rather then IS_BURNINGTRUE.
> Since there is a mix of numeric and dummy regressors I cannot selectively
> append TRUE to variables names as I don't have control of what regressors
> get imported (one month there might be 50 and another month 2).
> How can I stop lm() from padding onto a coefficent's name?
> I have no objection to post processing by finding and assasinating any name
> with the word TRUE appended to the end of a name but in that case then how
> do I change the coeff name?
> Maddening... who thought it would be a good idea to append things without
> asking? A simple lm(appendFactor=FALSE) would have been nice... took me 3
> hours to find out what was going wrong on this.... Grabbing coffee, a carton
> of cigs, and heading outside to smash my head with a brick to make the
> hurting stop....
> 	[[alternative HTML version deleted]]
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

Peter Ehlers
University of Calgary

More information about the R-help mailing list