简体   繁体   中英

psych FA biplot colour by group

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])

在此处输入图像描述

I

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"])

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM