psych FA biplot colour by group

473 Views Asked by At

I'm trying to use psych to perform factor analysis and create a biplot in which points are coloured by grouping variable.

I want the biplot to group by colour and only plot points not group labels.

Documentation suggests passing labels = NULL will plot points using character supplied by pch. However, doing so reduces the plot to only the first group (setosa).

Perhaps I am misunderstanding the group argument? Your help is appreciated.
Example:

library(psych)

data(iris)

iris_fa <- fa(iris[,-5],
              nfactors = 2)

biplot.psych(iris_fa,
             labels=iris[,5],
             choose = c(1,2),
             pch=16,
             group = iris[,5])

enter image description here

I

1

There are 1 best solutions below

1
On

You specified pch with one value, but you need three. (Otherwise it's like saying 16, 0, 0.) So when you added labels, it ignored pch, and used that parameter.

biplot.psych(iris_fa,
             # labels=iris[,5],
             # choose = c(1,2),
             pch= c(16, 16, 16),
             group = iris[,"Species"])

enter image description here