diff --git a/R/fortify-pca.R b/R/fortify-pca.R index a3d87d2..6f44b05 100755 --- a/R/fortify-pca.R +++ b/R/fortify-pca.R @@ -223,12 +223,16 @@ fortify.PCA <- function(model, data=NULL, type=c("observations", "variables"), P .id <- row.names(model[[i]]$coord) # scores on the PC - scores <- as.data.frame(model[[i]]$coord[,PC]) + if (class(model[[i]]$coord[,PC]) %in% "numeric") { + scores <- as.data.frame(t(model[[i]]$coord[,PC])) + } else { + scores <- as.data.frame(model[[i]]$coord[,PC]) + } names(scores) <- paste(".PC", PC, sep="") # square cosine : quality of the representation on the current space .cos2 <- model[[i]]$cos2[,PC] - if (length(PC > 1)) { + if (length(PC > 1) & !(class(.cos2) %in% "numeric")) { .cos2 <- rowSums(.cos2) }