Cruzamento de Dados

Passo 1: importação dos dados.

Importarei a base com informações acerca de Pokémons.

library(readxl)
df_pokemon.RData<-load("C:/Users/Marcial/Downloads/df_pokemon.RData")

Passo 2: escolher duas varáveis qualitativas.

Escolhi “Type_1” e “egg_group_1”

df$type_1<-as.factor(df$type_1)
df$egg_group_1<-as.factor(df$egg_group_1)

Passo 3: fazer a tabela cruzada.

tabela1<-table(df$type_1,df$egg_group_1)
tabela1
##           
##            bug ditto dragon fairy flying ground humanshape indeterminate
##   bug       59     0      0     0      0      0          0             0
##   dark       0     0      3     0      4     14          3             0
##   dragon     0     0      6     0      1      0          0             0
##   electric   0     0      0     2      0     13          2             4
##   fairy      0     0      0     9      2      3          0             0
##   fighting   0     0      0     0      0      7         16             0
##   fire       0     0      0     0      2     32          2             2
##   flying     0     0      0     0      2      0          0             0
##   ghost      0     0      0     0      0      0          0            18
##   grass      0     0      0    11      0     14          0             0
##   ground     5     0      0     0      0     13          0             0
##   ice        0     0      0     3      0      6          1             0
##   normal     0     1      0     6     23     44          0             0
##   poison     2     0      0     0      3      5          2             6
##   psychic    0     0      0     0      5      7         11             9
##   rock       0     0      0     1      3      0          0             0
##   steel      0     0      0     0      1      1          0             0
##   water      0     0      0     0      0      8          0             2
##           
##            mineral monster no-eggs plant water1 water2 water3
##   bug            1       0       1     0      2      0      0
##   dark           0       0       2     0      2      0      0
##   dragon         0       7       7     0      3      0      0
##   electric       5       5       5     0      0      0      0
##   fairy          0       0       3     0      0      0      0
##   fighting       0       0       2     0      0      0      0
##   fire           0       3       5     0      0      0      0
##   flying         0       0       1     0      0      0      0
##   ghost          2       0       1     2      0      0      0
##   grass          0      15       3    23      0      0      0
##   ground         4       5       2     0      1      0      0
##   ice            4       2       3     0      4      0      0
##   normal         3       7       7     0      2      0      0
##   poison         2       4       2     0      2      0      0
##   psychic        0       0      14     0      0      0      0
##   rock          12      11       3     0      4      0      6
##   steel         13       3       4     0      0      0      0
##   water          0      13       5     0     54     15      8

Passo 4: fazer a proporcionalidade.

prop.table(tabela1,1)*100
##           
##                  bug     ditto    dragon     fairy    flying    ground
##   bug      93.650794  0.000000  0.000000  0.000000  0.000000  0.000000
##   dark      0.000000  0.000000 10.714286  0.000000 14.285714 50.000000
##   dragon    0.000000  0.000000 25.000000  0.000000  4.166667  0.000000
##   electric  0.000000  0.000000  0.000000  5.555556  0.000000 36.111111
##   fairy     0.000000  0.000000  0.000000 52.941176 11.764706 17.647059
##   fighting  0.000000  0.000000  0.000000  0.000000  0.000000 28.000000
##   fire      0.000000  0.000000  0.000000  0.000000  4.347826 69.565217
##   flying    0.000000  0.000000  0.000000  0.000000 66.666667  0.000000
##   ghost     0.000000  0.000000  0.000000  0.000000  0.000000  0.000000
##   grass     0.000000  0.000000  0.000000 16.666667  0.000000 21.212121
##   ground   16.666667  0.000000  0.000000  0.000000  0.000000 43.333333
##   ice       0.000000  0.000000  0.000000 13.043478  0.000000 26.086957
##   normal    0.000000  1.075269  0.000000  6.451613 24.731183 47.311828
##   poison    7.142857  0.000000  0.000000  0.000000 10.714286 17.857143
##   psychic   0.000000  0.000000  0.000000  0.000000 10.869565 15.217391
##   rock      0.000000  0.000000  0.000000  2.500000  7.500000  0.000000
##   steel     0.000000  0.000000  0.000000  0.000000  4.545455  4.545455
##   water     0.000000  0.000000  0.000000  0.000000  0.000000  7.619048
##           
##            humanshape indeterminate   mineral   monster   no-eggs
##   bug        0.000000      0.000000  1.587302  0.000000  1.587302
##   dark      10.714286      0.000000  0.000000  0.000000  7.142857
##   dragon     0.000000      0.000000  0.000000 29.166667 29.166667
##   electric   5.555556     11.111111 13.888889 13.888889 13.888889
##   fairy      0.000000      0.000000  0.000000  0.000000 17.647059
##   fighting  64.000000      0.000000  0.000000  0.000000  8.000000
##   fire       4.347826      4.347826  0.000000  6.521739 10.869565
##   flying     0.000000      0.000000  0.000000  0.000000 33.333333
##   ghost      0.000000     78.260870  8.695652  0.000000  4.347826
##   grass      0.000000      0.000000  0.000000 22.727273  4.545455
##   ground     0.000000      0.000000 13.333333 16.666667  6.666667
##   ice        4.347826      0.000000 17.391304  8.695652 13.043478
##   normal     0.000000      0.000000  3.225806  7.526882  7.526882
##   poison     7.142857     21.428571  7.142857 14.285714  7.142857
##   psychic   23.913043     19.565217  0.000000  0.000000 30.434783
##   rock       0.000000      0.000000 30.000000 27.500000  7.500000
##   steel      0.000000      0.000000 59.090909 13.636364 18.181818
##   water      0.000000      1.904762  0.000000 12.380952  4.761905
##           
##                plant    water1    water2    water3
##   bug       0.000000  3.174603  0.000000  0.000000
##   dark      0.000000  7.142857  0.000000  0.000000
##   dragon    0.000000 12.500000  0.000000  0.000000
##   electric  0.000000  0.000000  0.000000  0.000000
##   fairy     0.000000  0.000000  0.000000  0.000000
##   fighting  0.000000  0.000000  0.000000  0.000000
##   fire      0.000000  0.000000  0.000000  0.000000
##   flying    0.000000  0.000000  0.000000  0.000000
##   ghost     8.695652  0.000000  0.000000  0.000000
##   grass    34.848485  0.000000  0.000000  0.000000
##   ground    0.000000  3.333333  0.000000  0.000000
##   ice       0.000000 17.391304  0.000000  0.000000
##   normal    0.000000  2.150538  0.000000  0.000000
##   poison    0.000000  7.142857  0.000000  0.000000
##   psychic   0.000000  0.000000  0.000000  0.000000
##   rock      0.000000 10.000000  0.000000 15.000000
##   steel     0.000000  0.000000  0.000000  0.000000
##   water     0.000000 51.428571 14.285714  7.619048

Conclusão: Vimos que o tipo “bug” tanto de Tipos de Pokémon quanto de grupos de ovos é o que mais aparece em ambas as tabelas. Sendo a linha bugXbug a com maior proporcionalidade.