Reputation: 591
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
Upvotes: 1
Views: 633
Reputation: 18744
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"])
Upvotes: 2