for loop - Running factor analysis using split function in R -
i have following dataset :
mkt econ_unemp econ_gas open 504 0.0743088 3.461 38 504 0.0740673 3.448 38 504 0.0740673 3.455 38 504 0.0740673 3.42 38 504 0.072682 3.391 38 505 0.0692244 3.345 38 505 0.0692244 3.381 38 505 0.0692244 3.484 38 505 0.0692244 3.488 38 i need run factor analysis on 3 variables market used split function in r split data:
splitx<-split(data,data$dma) and tried running factor analysis follows:
for (i in 1:length(splitx)) { fa <- factanal(splitx[[i]],factors =1) } but getting following error:
error in optim(start, fafn, fagr, method = "l-bfgs-b", lower = lower,:non-finite value supplied optim i hope information provided sufficient. can me fix this.
regards
by(data[, -1], data[, 1], factanal, factors = 1) that should trick, assuming mkt split variable.
Comments
Post a Comment