Extracting factors from "factanal"
Hi
-----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- project.org] On Behalf Of Virgile Capo-Chichi Sent: Wednesday, January 02, 2013 9:33 AM To: R help Subject: [R] Extracting factors from "factanal" Dear R users Happy New year to all for a start. Below is some data that I ran a factor analysis on. Using $score prints the scores for each of the three factors. However, I would like to access those factors as variable for new computations. How do I do that? In SPSS we just call fact1_1, fact2_1 etc.. Thanks for your suggestions. V ============ v1 <- c(1,1,1,1,1,1,1,1,1,1,3,3,3,3,3,4,5,6) v2 <- c(1,2,1,1,1,1,2,1,2,1,3,4,3,3,3,4,6,5) v3 <- c(3,3,3,3,3,1,1,1,1,1,1,1,1,1,1,5,4,6) v4 <- c(3,3,4,3,3,1,1,2,1,1,1,1,2,1,1,5,6,4) v5 <- c(1,1,1,1,1,3,3,3,3,3,1,1,1,1,1,6,4,5) v6 <- c(1,1,1,2,1,3,3,3,4,3,1,1,1,2,1,6,5,4) m1 <- cbind(v1,v2,v3,v4,v5,v6) factanal(m1, factors = 3,scores = "Bartlett")$scores
myscores <- factanal(m1, factors = 3,scores = "Bartlett")$scores
myscores[,1]
[1] -0.9039949 -0.8685952 -0.9082818 -1.0021975 -0.9039949 -0.7452711 [7] -0.7098714 -0.7495580 -0.8080740 -0.7452711 0.9272282 0.9626279 [13] 0.9229413 0.8290256 0.9272282 0.4224366 1.4713902 1.8822320 or
myscores[,"Factor1"]
[1] -0.9039949 -0.8685952 -0.9082818 -1.0021975 -0.9039949 -0.7452711 [7] -0.7098714 -0.7495580 -0.8080740 -0.7452711 0.9272282 0.9626279 [13] 0.9229413 0.8290256 0.9272282 0.4224366 1.4713902 1.8822320
selects a factor score. myscore is a matrix so you cannot use $ notation. However you can convert it to data frame. Regards Petr
[[alternative HTML version deleted]]
______________________________________________ R-help at 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.