aiorazabala / qmethod

R package to analyse Q methodology data
GNU General Public License v2.0
34 stars 18 forks source link

qmethod with reorder = TRUE gives false component names #275

Closed maxheld83 closed 9 years ago

maxheld83 commented 9 years ago

There's a little inconsistency here:

When it reorders (as it does by default) as per #263, principal::psych retains the original column names, as in:

pca.results <- principal(r = cor.data, nfactors = nfactors, rotate = rotation, n.obs = nrow(dataset), covar = FALSE)
loa <- as.data.frame(unclass(pca.results$loadings)) #PCA from {psych} for factor loadings
loa

yields:

            PC2         PC1         PC3
US1  0.19090031  0.76583098 -0.16829944
US2 -0.06552370  0.82578471  0.10674419
US3  0.81073850 -0.01642114 -0.09294327
US4  0.77564922  0.22983558  0.27115532
JP5 -0.83345268  0.15438190  0.02554101
CA6  0.14605752 -0.18452178  0.88487489
UK7  0.14131112 -0.34862230  0.73900317
US8 -0.08906645  0.66252588 -0.17048799
FR9  0.20377209 -0.18284105 -0.44813857

notice, however, that qmethod then re-assigns names, irrespective of this turning around in principal::psych:

colnames(loa) <- paste0("f", 1:ncol(loa))
loa

yields:

             f1          f2          f3
US1  0.19090031  0.76583098 -0.16829944
US2 -0.06552370  0.82578471  0.10674419
US3  0.81073850 -0.01642114 -0.09294327
US4  0.77564922  0.22983558  0.27115532
JP5 -0.83345268  0.15438190  0.02554101
CA6  0.14605752 -0.18452178  0.88487489
UK7  0.14131112 -0.34862230  0.73900317
US8 -0.08906645  0.66252588 -0.17048799
FR9  0.20377209 -0.18284105 -0.44813857

That's a little confusing, especially because f1 etc is the same naming if the results are not rotated.

I think we really need to get around to streamlining the "factor"-naming conventions as per #264

maxheld83 commented 9 years ago

in the meantime, this is a "bug" (eh, more of an inconsistency) that I think we won't fix if reorder = TRUE, just to preserve backwards compatibility.

If reorder = FALSE, the problem goes away anyway