0

biplot下面的代码产生的我试图摆脱红线。如果有人可以提供帮助,我将不胜感激。

library(psych)
data(bfi)
fa2 <- fa(bfi[16:25],2)  #factor analysis
fa2$scores <- fa2$scores[1:100,]  #just take the first 100
biplot(fa2,pch=c(24,21)[bfi[1:100,"gender"]],bg=c("blue","red")[bfi[1:100,"gender"]],
main="Biplot of Conscientiousness and Neuroticism by gender")

在此处输入图像描述

4

2 回答 2

1

无论出于何种原因,该psych库决定重新编写它自己的双标图,因此它忽略了许多标准参数。您可以创建自己的版本,只需删除箭头图。这种方法有点 hacky,但经过psych_1.4.5. 只需验证

body(biplot.psych)[[c(11,3,12)]]

返回

arrows(0, 0, x$loadings[, 1L] * 0.8, x$loadings[, 2L] * 0.8, 
    col = col[2L], length = arrow.len)

以确保我们正在更改正确的行。然后你可以做

biplot.psych2<-biplot.psych
body(biplot.psych2)[[11]][[3]][[12]]<-NULL

然后调用我们的新函数

biplot.psych2(fa2,pch=c(24,21)[bfi[1:100,"gender"]],
    bg=c("blue","red")[bfi[1:100,"gender"]],
    main="Biplot of Conscientiousness and Neuroticism by gender")

要得到

在此处输入图像描述

于 2014-08-16T06:45:50.850 回答
0

在您发布问题几个月后,这里有一个快速答案。您实际要求的不是双标图(包括因子得分和因子载荷),而只是因子得分的图。使用您的示例,只需

plot(fa2$scores,bg=c("blue","re​​d")[bfi[1:100,"gender"]],pch=c(24,21)[bfi[1:100,"gender"] ],ylim=c(-3,3),xlim=c(-3,3))。

于 2015-02-14T18:40:18.617 回答