繁体   English   中英

显示 R 中 plot 上两列之间的相关性

[英]Display correlation between two columns on a plot in R

我有一个包含一些数据的 csv 文件。 以下是其中的数据示例(来自 R Studio): 在此处输入图像描述

和 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

我如何在 plot 上显示某个(或每个X_map两列之间的相关性: starting_ctmap_winner 这样做的目的是确定starting_ct = 1map_winner = 1之间是否存在相关性。

用正常的话来说:我想看看start_ct事实是否影响map_winner某些(或每个X_map

我想在 plot 上显示这些数据,因此我可以进一步使用它来创建预测 model。

编辑:这是使用以下答案中的代码的结果: 在此处输入图像描述

你可以从这样的事情开始:

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

显然,您的示例数据是一派胡言。

在此处输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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