[Rd] Variable names with spaces in lm

Gabor Grothendieck ggrothendieck at gmail.com
Mon May 9 15:18:46 CEST 2005


'lm' gives an error when using variables with spaces in them
in certain cases (but not all):

	my.list <- list(`a 1` = 1:4, `a 2` = 11:14)
	lm(`a 1` ~ ., my.list) # Error : Object "a.1" not found

# The following work ok so it does work in many cases:

	lm(`a 1` ~ ., as.data.frame(my.list, optional = TRUE)) # ok
	lm(`a 1` ~ `a 2`, my.list) # ok

Admittedly ?lm says that the data argument should be
a data frame or environment so this is not strictly a bug
but it seems to work with a list and the code even seems to 
coerce it to a data frame.

I am using Windows XP "R version 2.1.0, 2005-04-18".



More information about the R-devel mailing list