Atividade 06 - Análise de diagrama de dispersão e matriz de correlação

Introdução

Este trabalho tem por finalidade analisar duas variáveis quantitativas, através da elaboração de um diagrama de dispersão e de uma matriz de correlação, baseando-se pelo banco de dados “FifaData.csv”

Carregando a base de dados

library(readr)
FifaData <- read_csv("C:/Users/19801926775/Desktop/Base_de_dados-master/FifaData.csv")
View(FifaData)

Mostrando a base de dados

library(readxl)
library(flextable)
library(dplyr)
library(ggplot2)
head(FifaData) %>% flextable() %>% theme_tron_legacy()

Name

Nationality

National_Position

National_Kit

Club

Club_Position

Club_Kit

Club_Joining

Contract_Expiry

Rating

Height

Weight

Preffered_Foot

Birth_Date

Age

Preffered_Position

Work_Rate

Weak_foot

Skill_Moves

Ball_Control

Dribbling

Marking

Sliding_Tackle

Standing_Tackle

Aggression

Reactions

Attacking_Position

Interceptions

Vision

Composure

Crossing

Short_Pass

Long_Pass

Acceleration

Speed

Stamina

Strength

Balance

Agility

Jumping

Heading

Shot_Power

Finishing

Long_Shots

Curve

Freekick_Accuracy

Penalties

Volleys

GK_Positioning

GK_Diving

GK_Kicking

GK_Handling

GK_Reflexes

Cristiano Ronaldo

Portugal

LS

7

Real Madrid

LW

7

07/01/2009

2,021

94

185 cm

80 kg

Right

02/05/1985

32

LW/ST

High / Low

4

5

93

92

22

23

31

63

96

94

29

85

86

84

83

77

91

92

92

80

63

90

95

85

92

93

90

81

76

85

88

14

7

15

11

11

Lionel Messi

Argentina

RW

10

FC Barcelona

RW

10

07/01/2004

2,018

93

170 cm

72 kg

Left

06/24/1987

29

RW

Medium / Medium

4

4

95

97

13

26

28

48

95

93

22

90

94

77

88

87

92

87

74

59

95

90

68

71

85

95

88

89

90

74

85

14

6

15

11

8

Neymar

Brazil

LW

10

FC Barcelona

LW

11

07/01/2013

2,021

92

174 cm

68 kg

Right

02/05/1992

25

LW

High / Medium

5

5

95

96

21

33

24

56

88

90

36

80

80

75

81

75

93

90

79

49

82

96

61

62

78

89

77

79

84

81

83

15

9

15

9

11

Luis Suárez

Uruguay

LS

9

FC Barcelona

ST

9

07/11/2014

2,021

92

182 cm

85 kg

Right

01/24/1987

30

ST

High / Medium

4

4

91

86

30

38

45

78

93

92

41

84

83

77

83

64

88

77

89

76

60

86

69

77

87

94

86

86

84

85

88

33

27

31

25

37

Manuel Neuer

Germany

GK

1

FC Bayern

GK

1

07/01/2011

2,021

92

193 cm

92 kg

Right

03/27/1986

31

GK

Medium / Medium

4

1

48

30

10

11

10

29

85

12

30

70

70

15

55

59

58

61

44

83

35

52

78

25

25

13

16

14

11

47

11

91

89

95

90

89

De Gea

Spain

GK

1

Manchester Utd

GK

1

07/01/2011

2,019

90

193 cm

82 kg

Right

11/07/1990

26

GK

Medium / Medium

3

1

31

13

13

13

21

38

88

12

30

68

60

17

31

32

56

56

25

64

43

57

67

21

31

13

12

21

19

40

13

86

88

87

85

90

Resumo da base de dados

summary(FifaData)
##      Name           Nationality        National_Position   National_Kit  
##  Length:17588       Length:17588       Length:17588       Min.   : 1.00  
##  Class :character   Class :character   Class :character   1st Qu.: 6.00  
##  Mode  :character   Mode  :character   Mode  :character   Median :12.00  
##                                                           Mean   :12.22  
##                                                           3rd Qu.:18.00  
##                                                           Max.   :36.00  
##                                                           NA's   :16513  
##      Club           Club_Position         Club_Kit     Club_Joining      
##  Length:17588       Length:17588       Min.   : 1.00   Length:17588      
##  Class :character   Class :character   1st Qu.: 9.00   Class :character  
##  Mode  :character   Mode  :character   Median :18.00   Mode  :character  
##                                        Mean   :21.29                     
##                                        3rd Qu.:27.00                     
##                                        Max.   :99.00                     
##                                        NA's   :1                         
##  Contract_Expiry     Rating         Height             Weight         
##  Min.   :2017    Min.   :45.00   Length:17588       Length:17588      
##  1st Qu.:2017    1st Qu.:62.00   Class :character   Class :character  
##  Median :2019    Median :66.00   Mode  :character   Mode  :character  
##  Mean   :2019    Mean   :66.17                                        
##  3rd Qu.:2020    3rd Qu.:71.00                                        
##  Max.   :2023    Max.   :94.00                                        
##  NA's   :1                                                            
##  Preffered_Foot      Birth_Date             Age        Preffered_Position
##  Length:17588       Length:17588       Min.   :17.00   Length:17588      
##  Class :character   Class :character   1st Qu.:22.00   Class :character  
##  Mode  :character   Mode  :character   Median :25.00   Mode  :character  
##                                        Mean   :25.46                     
##                                        3rd Qu.:29.00                     
##                                        Max.   :47.00                     
##                                                                          
##   Work_Rate           Weak_foot      Skill_Moves     Ball_Control  
##  Length:17588       Min.   :1.000   Min.   :1.000   Min.   : 5.00  
##  Class :character   1st Qu.:3.000   1st Qu.:2.000   1st Qu.:53.00  
##  Mode  :character   Median :3.000   Median :2.000   Median :63.00  
##                     Mean   :2.934   Mean   :2.303   Mean   :57.97  
##                     3rd Qu.:3.000   3rd Qu.:3.000   3rd Qu.:69.00  
##                     Max.   :5.000   Max.   :5.000   Max.   :95.00  
##                                                                    
##    Dribbling       Marking      Sliding_Tackle  Standing_Tackle   Aggression   
##  Min.   : 4.0   Min.   : 3.00   Min.   : 5.00   Min.   : 3.00   Min.   : 2.00  
##  1st Qu.:47.0   1st Qu.:22.00   1st Qu.:23.00   1st Qu.:26.00   1st Qu.:44.00  
##  Median :60.0   Median :48.00   Median :51.00   Median :54.00   Median :59.00  
##  Mean   :54.8   Mean   :44.23   Mean   :45.57   Mean   :47.44   Mean   :55.92  
##  3rd Qu.:68.0   3rd Qu.:64.00   3rd Qu.:64.00   3rd Qu.:66.00   3rd Qu.:70.00  
##  Max.   :97.0   Max.   :92.00   Max.   :95.00   Max.   :92.00   Max.   :96.00  
##                                                                                
##    Reactions     Attacking_Position Interceptions       Vision     
##  Min.   :29.00   Min.   : 2.00      Min.   : 3.00   Min.   :10.00  
##  1st Qu.:55.00   1st Qu.:37.00      1st Qu.:26.00   1st Qu.:43.00  
##  Median :62.00   Median :54.00      Median :52.00   Median :54.00  
##  Mean   :61.77   Mean   :49.59      Mean   :46.79   Mean   :52.71  
##  3rd Qu.:68.00   3rd Qu.:64.00      3rd Qu.:64.00   3rd Qu.:64.00  
##  Max.   :96.00   Max.   :94.00      Max.   :93.00   Max.   :94.00  
##                                                                    
##    Composure        Crossing       Short_Pass      Long_Pass     Acceleration  
##  Min.   : 5.00   Min.   : 6.00   Min.   :10.00   Min.   : 7.0   Min.   :11.00  
##  1st Qu.:47.00   1st Qu.:38.00   1st Qu.:52.00   1st Qu.:42.0   1st Qu.:57.00  
##  Median :57.00   Median :54.00   Median :62.00   Median :56.0   Median :68.00  
##  Mean   :55.85   Mean   :49.74   Mean   :58.12   Mean   :52.4   Mean   :65.29  
##  3rd Qu.:66.00   3rd Qu.:64.00   3rd Qu.:68.00   3rd Qu.:64.0   3rd Qu.:75.00  
##  Max.   :94.00   Max.   :91.00   Max.   :92.00   Max.   :93.0   Max.   :96.00  
##                                                                                
##      Speed          Stamina         Strength        Balance     
##  Min.   :11.00   Min.   :10.00   Min.   :20.00   Min.   :10.00  
##  1st Qu.:58.00   1st Qu.:57.00   1st Qu.:57.00   1st Qu.:56.00  
##  Median :68.00   Median :66.00   Median :66.00   Median :65.00  
##  Mean   :65.48   Mean   :63.48   Mean   :65.09   Mean   :64.01  
##  3rd Qu.:75.00   3rd Qu.:74.00   3rd Qu.:74.00   3rd Qu.:74.00  
##  Max.   :96.00   Max.   :95.00   Max.   :98.00   Max.   :97.00  
##                                                                 
##     Agility         Jumping         Heading        Shot_Power   
##  Min.   :11.00   Min.   :15.00   Min.   : 4.00   Min.   : 3.00  
##  1st Qu.:55.00   1st Qu.:58.00   1st Qu.:45.00   1st Qu.:45.00  
##  Median :65.00   Median :65.00   Median :56.00   Median :59.00  
##  Mean   :63.21   Mean   :64.92   Mean   :52.39   Mean   :55.58  
##  3rd Qu.:74.00   3rd Qu.:73.00   3rd Qu.:65.00   3rd Qu.:69.00  
##  Max.   :96.00   Max.   :95.00   Max.   :94.00   Max.   :93.00  
##                                                                 
##    Finishing       Long_Shots       Curve       Freekick_Accuracy
##  Min.   : 2.00   Min.   : 4.0   Min.   : 6.00   Min.   : 4.00    
##  1st Qu.:29.00   1st Qu.:32.0   1st Qu.:34.00   1st Qu.:31.00    
##  Median :48.00   Median :52.0   Median :48.00   Median :42.00    
##  Mean   :45.16   Mean   :47.4   Mean   :47.18   Mean   :43.38    
##  3rd Qu.:61.00   3rd Qu.:63.0   3rd Qu.:62.00   3rd Qu.:57.00    
##  Max.   :95.00   Max.   :91.0   Max.   :92.00   Max.   :93.00    
##                                                                  
##    Penalties        Volleys      GK_Positioning    GK_Diving    
##  Min.   : 7.00   Min.   : 3.00   Min.   : 1.00   Min.   : 1.00  
##  1st Qu.:39.00   1st Qu.:30.00   1st Qu.: 8.00   1st Qu.: 8.00  
##  Median :50.00   Median :44.00   Median :11.00   Median :11.00  
##  Mean   :49.17   Mean   :43.28   Mean   :16.61   Mean   :16.82  
##  3rd Qu.:61.00   3rd Qu.:57.00   3rd Qu.:14.00   3rd Qu.:14.00  
##  Max.   :96.00   Max.   :93.00   Max.   :91.00   Max.   :89.00  
##                                                                 
##    GK_Kicking     GK_Handling     GK_Reflexes  
##  Min.   : 1.00   Min.   : 1.00   Min.   : 1.0  
##  1st Qu.: 8.00   1st Qu.: 8.00   1st Qu.: 8.0  
##  Median :11.00   Median :11.00   Median :11.0  
##  Mean   :16.46   Mean   :16.56   Mean   :16.9  
##  3rd Qu.:14.00   3rd Qu.:14.00   3rd Qu.:14.0  
##  Max.   :95.00   Max.   :91.00   Max.   :90.0  
## 

Diagrama de dispersão

plot(FifaData$Age, FifaData$Rating, col="#52de9d",
       pch=19, main="Diagrama de Dispersão",
       xlab = "Idade",
       ylab = "Avaliação")
abline(lsfit(FifaData$Age, FifaData$Rating), col="#4f3620")

cor(FifaData$Age,FifaData$Rating)
## [1] 0.4582763

Matriz de correlação

library(corrplot)
FifaData %>% select(Age, Rating, Speed, Agility, Dribbling, Marking) %>%
  filter(!is.na(Age)) %>%
  cor() %>% corrplot(method = "circle")

Conclusão

Este banco de dados apresenta 53 variáveis. As duas variáveis quantitativas que resolvi analisar neste trabalho são Idade e Avaliação. A hipótese levantada é se a idade dos jogadores interfere na avaliação dos mesmos. O diagrama de dispersão mostra que correlação entre a idade e a avaliação dos jogadores é de 0,45, ou seja, é uma correlação fraca.

Já a matriz de correlação mostrou que a variável que possui maior grau de relação e está mais positivamente correlacionada com a idade é “Rating”, com índices acima de 0,6. As variáveis com menor correlação são “Marking” e “Dribbling”.