[R] Including a large number of variables in a formula.

Rolando I. Valdez rv@|dez35 @end|ng |rom u@bc@edu@mx
Wed Jun 5 06:46:55 CEST 2019


Hello,

I have almost 40 variables that I am trying to include in a formula.

I tried to include them using as.formula(), however the variables do not
follow a patter in the name. e.g. These variables are named like: lvacb23
lvacb30 lvacb300  lvacb40 .....  lvacb81.

> lvadd <- paste0("lvacb", 23:81)
> (fmla <- as.formula(paste("lwage ~ ", paste(lvadd, collapse = "+"))))
> fit <- lm(fmla, data = wageszm14)
Error in eval(predvars, data, env) : object 'lvacb24' not found

The variable lvacb24 doesn't exist, because from lvacb23 it jumps to
lvacb30.

Thanks in advance for any help.
-- 
Rolando Valdez
Facultad de Economía y Relaciones Internacionales
Universidad Autónoma de Baja California

	[[alternative HTML version deleted]]



More information about the R-help mailing list