首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在数据框中使用不同因子的相关散点图

在数据框中使用不同因子的相关散点图
EN

Stack Overflow用户
提问于 2020-06-02 21:26:34
回答 1查看 36关注 0票数 0

如果标题不清楚,请提前道歉。我有一个如下的DF RatingScores

代码语言:javascript
复制
head(RatingScores)

    PP Condition QuoteType Rating Correct
1  pp1 Disfluent        BS   3.15       7
2  pp1 Disfluent     Motiv   4.15       7
3 pp10 Disfluent     Motiv   3.75       6
4 pp10 Disfluent        BS   1.45       6
5 pp11    Fluent     Motiv   4.45       6
6 pp11    Fluent        BS   3.50       6 

我的目标是执行RatingCorrect之间的相关性分析,但我需要每个Condition * QuoteType因子的Rating。例如,将来自Disfluent*BSRatingCorrect关联(即使用行1和行4)。我的第二个目标是在散点图上绘制这些相关性,并在图上绘制每条相关线。

到目前为止,我唯一的解决方案是相应地对数据进行子集,然后使用ggscatter绘制单独的图形,但是我不能使用par(new=TRUE)将它们相互覆盖。

到目前为止,我是这样对数据进行子集的:

代码语言:javascript
复制
DBS=subset(RatingScores,RatingScores$Condition=="Disfluent"&RatingScores$QuoteType=="BS")
FBS=subset(RatingScores,RatingScores$Condition=="Fluent"&RatingScores$QuoteType=="BS")
DMo=subset(RatingScores,RatingScores$Condition=="Disfluent"&RatingScores$QuoteType=="Motiv")
FMo=subset(RatingScores,RatingScores$Condition=="Fluent"&RatingScores$QuoteType=="Motiv")

然后像这样画出每一个:

代码语言:javascript
复制
ggscatter(DMo, x = "Rating", y = "Correct", 
                add = "reg.line",point = F,color = "green", conf.int = F, 
                cor.coef = TRUE, cor.method = "pearson", title = "Disfluent Mo",
                xlab = "Rating", ylab = "CRT Score")

如果有更有效和更清晰的方法来做这件事,我将非常感谢任何帮助。提前谢谢。

EN

回答 1

Stack Overflow用户

发布于 2020-06-03 00:59:20

你在找这个吗?

代码语言:javascript
复制
ggscatter(RatingScores, x = "Rating", y = "Correct", 
          add = "reg.line",point = F,color = "green", conf.int = F, 
          cor.coef = TRUE, cor.method = "pearson", title = "Disfluent Mo",
          xlab = "Rating", ylab = "CRT Score") +
  facet_wrap(Condition ~ QuoteType)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62153093

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档