library(psych) par1 <- as.numeric(par1) x <- t(x) nrows <- length(x[,1]) ncols <- length(x[1,]) y <- array(as.double(x[1:nrows,2:ncols]),dim=c(nrows,ncols-1)) colnames(y) <- colnames(x)[2:ncols] rownames(y) <- x[,1] y fit <- principal(y, nfactors=par1, rotate='varimax') fit fs <- factor.scores(y,fit) fs bitmap(file='test2.png') plot(fs$scores,pch=20) text(fs$scores,labels=rownames(y),pos=3) dev.off() load(file='createtable') a<-table.start() a<-table.row.start(a) a<-table.element(a,'Rotated Factor Loadings',par1+1,TRUE) a<-table.row.end(a) a<-table.row.start(a) a<-table.element(a,'Variables',1,TRUE) for (i in 1:par1) { a<-table.element(a,paste('Factor',i,sep=''),1,TRUE) } a<-table.row.end(a) for (j in 1:length(fit$loadings[,1])) { a<-table.row.start(a) a<-table.element(a,rownames(fit$loadings)[j],header=TRUE) for (i in 1:par1) { a<-table.element(a,round(fit$loadings[j,i],3)) } a<-table.row.end(a) } a<-table.end(a) table.save(a,file='mytable.tab')
|