I need to run factor analysis based on markets so I created a list using the split function:
splitx <- split(data,list(data$econ_gas,data$econ_unemp,data$open),data$MKT)
And then I have looped through the 'splitx' list to run the factor analysis as follows:
for (i in 1:length(splitx))
{
factanal(~ ., data = splitx, factors = 1)
}
I get the following error:
Error in factanal(splitx, factors = 1) : factor analysis applies only to numerical variables.
I am also giving a snapshot of the data I am working on:
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
Can I get some help on this.