Dear R Help team, I'm having some problems running a discriminant analysis (MASS:lda) over my data, i have a grouping variable coming from a previous cluster analysis and several discriminators (78 actually). I'm trying to run lda using column index as independent variable in the formula like it's done in the help page for ?formula:
lda(Grupo~paste(names(cien[,3:80]),collapse="+"),data=cien)
but i get the following error: Error in model.frame.default(formula = Grupo ~ paste(names(cien[, 3:80]), : different variable length (found in 'paste(names(cien[, 3:80]), collapse = "+")') (This is my english translation of the error msg while i use R in spanish so it should look different in your machines) The funny thing is that if i use:
paste(names(cien[,3:80]),collapse="+")
[1] "X.SO.M2+X.SO.M4+X.SO.M6+X.SO.M8+X.SO.M10+X.SO.M12+..... and then copy and paste the result in the formula:
lda(Grupo~X.SO.M2+X.SO.M4+X.SO.M6+X.SO.M8+X.SO.M10+X.SO.M12+....,data=cien)
then there's no error!!! the lda runs just fine.
I know i might be doing something wrong but i don't know where so
could you please enlighten me? Thanks in advance
PD. Here's a piece of the data:
NOMEST Grupo X.SO.M2 X.SO.M4
X.SO.M6 X.SO.M8 .....(78 var)
1 Ci?naga La Ahuyama 3 95.1 152.3
115.3 97.6
2 Boca del Ca?o Grande 3 91.0 104.2
131.7 89.4
3 Buenavista 3 115.6
102.9 122.0 110.5
4 Ci?naga El Loro 1 104.0
80.9 68.5 50.7
.
.
.
--
Marcos Antonio Carvajalino Fern?ndez
Estudiante de Ingenier?a Ambiental y Sanitaria
Universidad del Magdalena
Santa Marta, Colombia