[英]Display correlation between two columns on a plot in R
I have a csv file with some data.我有一个包含一些数据的 csv 文件。 Here is the example of data from it (from R Studio):以下是其中的数据示例(来自 R Studio):
and result of data.frame(df):和 data.frame(df) 的结果:
> data.frame(df)
date team_1 team_2 X_map result_1 result_2 map_winner starting_ct
1 17-03-20 Natus Vincere North Nuke 10 16 2 1
2 17-03-20 Natus Vincere North Dust2 10 16 2 1
3 01-03-20 Natus Vincere Astralis Nuke 16 5 1 1
4 01-03-20 Natus Vincere Astralis Dust2 16 5 1 2
5 01-03-20 Natus Vincere Liquid Dust2 16 11 1 2
6 29-02-20 Natus Vincere Liquid Mirage 16 13 1 1
7 29-02-20 Natus Vincere FaZe Inferno 16 14 1 1
8 28-02-20 Natus Vincere FaZe Nuke 8 16 2 1
9 28-02-20 Natus Vincere FaZe Dust2 16 6 1 2
10 27-02-20 Natus Vincere fnatic Dust2 7 16 2 2
How could I display on a plot the correlation between two columns: starting_ct and map_winner , for a certain ( or each ) X_map .我如何在 plot 上显示某个(或每个) X_map两列之间的相关性: starting_ct和map_winner 。 The purpose of this is to identify if is there a correlation between starting_ct = 1 and map_winner = 1 .这样做的目的是确定starting_ct = 1和map_winner = 1之间是否存在相关性。
In normal words: I want to see if the starting_ct fact is influencing the map_winner for certain ( or each ) X_map .用正常的话来说:我想看看start_ct事实是否影响map_winner某些(或每个) X_map 。
I would like to display this data on a plot, so I could use it further for creating a predictive model.我想在 plot 上显示这些数据,因此我可以进一步使用它来创建预测 model。
EDIT : this is the result of using the code from answer below:编辑:这是使用以下答案中的代码的结果:
You can start with something like this:你可以从这样的事情开始:
library(ggplot2)
ggplot(data, aes(x = starting_ct, y = map_winner)) +
geom_point()+
facet_wrap(vars(X_map)) +
geom_smooth(method = "lm", colour = "green", fill = "green") +
theme_light()
Obviously with your example data is quite a nonsense.显然,您的示例数据是一派胡言。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.