Not sure how to get formula to handle spaces, but to get going you can just change the names in the data frame after you have read it, e.g.
names(mcReg) <- make.names(names(mcReg)) will (usually) give you Small.Bank.Acquired. Allan On 15/07/09 15:40, Idgarad wrote: > I am reading regressors from an excel file (I have no control over the file) > and some of the element names have spaces: > > i.e. "Small Bank Aquired" > > but I have found that lm(SourceData ~ . - "Small Bank Aquired", mcReg) > doesn't work (mcReg = modelCurrentRegressors) > > As they are toggles I have ran them through factor() to be treated propertly > as 0 or 1 but due to the fact I am grabbing automagically the first 2/3rds > of the data some of the regressors are either all 0s or all 1s accordingly > so I need to take them out of the model by hand for now until I find a nice > automatic method for removing regressors that only have 1 factor. > > So Primarily: how do I handle names that include spaces in this context and > as a bonus: Anyone have a nice method for yanking regressors that only have > a single factor in them from the lm() function? > > > e.g. (for the following 30 elements) > 0,0,0,0,0,0,0,0,0,0, > 0,0,0,0,0,0,0,0,0,0, > 1,1,1,1,1,1,1,1,1,1 > > As you can see grabbing the first 2/3rds is all 0s and the last 1/3rd is all > ones (doing in-sample forecast diagnostic building the model only on the > first 2/3rds of data, then forecasting the next 1/3rd and comparing.) > > Sorry if I am rambling a bit, still on cup of coffee #1... > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@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. > [[alternative HTML version deleted]] ______________________________________________ R-help@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.