PRACTICA CALIFICADA BIVARIADA

Parte 1 (Indice de libertades)

Carga de datos

Link2="https://en.wikipedia.org/wiki/List_of_freedom_indices"
Path2='//*[@id="mw-content-text"]/div[1]/table[2]'
Ifreedom=htmltab::htmltab(Link2,Path2)
names(Ifreedom)
## [1] "Country"                        "Freedom in the World 2020"     
## [3] "2020 Index of Economic Freedom" "2020 Press Freedom Index"      
## [5] "2019 Democracy Index"
names(Ifreedom)=c("country","Freedom","eco","press","demo")

Covertimos a numericos

str(Ifreedom)
## 'data.frame':    198 obs. of  5 variables:
##  $ country: chr  " Afghanistan" " Albania" " Algeria" " Andorra" ...
##  $ Freedom: chr  "not free" "partly free" "not free" "free" ...
##  $ eco    : chr  "mostly unfree" "moderately free" "repressed" "n/a" ...
##  $ press  : chr  "difficult situation" "noticeable problems" "difficult situation" "satisfactory situation" ...
##  $ demo   : chr  "authoritarian regime" "hybrid regime" "hybrid regime" "n/a" ...

Pregunta 1

feco=formula(eco ~ press)
aggregate(feco, Ifreedom, mean)
## Warning in mean.default(X[[i]], ...): argument is not numeric or logical:
## returning NA

## Warning in mean.default(X[[i]], ...): argument is not numeric or logical:
## returning NA

## Warning in mean.default(X[[i]], ...): argument is not numeric or logical:
## returning NA

## Warning in mean.default(X[[i]], ...): argument is not numeric or logical:
## returning NA

## Warning in mean.default(X[[i]], ...): argument is not numeric or logical:
## returning NA

## Warning in mean.default(X[[i]], ...): argument is not numeric or logical:
## returning NA
##                    press eco
## 1    difficult situation  NA
## 2         good situation  NA
## 3                    n/a  NA
## 4    noticeable problems  NA
## 5 satisfactory situation  NA
## 6 very serious situation  NA
columna=Ifreedom$eco
fila=Ifreedom$press
(t=table(fila,columna))
##                         columna
## fila                     free moderately free mostly free mostly unfree n/a
##   difficult situation       0              16           4            19   2
##   good situation            3               4           7             0   0
##   n/a                       0               3           1             3   6
##   noticeable problems       1              23           7            28   0
##   satisfactory situation    1              13          12             6   5
##   very serious situation    1               3           0             6   5
##                         columna
## fila                     repressed
##   difficult situation            6
##   good situation                 0
##   n/a                            1
##   noticeable problems            3
##   satisfactory situation         1
##   very serious situation         8

Respuesta: la libertad económica SI está relacionada con la libertad de prensa

Pregunta 2

fecodemo=formula(eco ~ demo)
aggregate(fecodemo, Ifreedom, mean)
## Warning in mean.default(X[[i]], ...): argument is not numeric or logical:
## returning NA

## Warning in mean.default(X[[i]], ...): argument is not numeric or logical:
## returning NA

## Warning in mean.default(X[[i]], ...): argument is not numeric or logical:
## returning NA

## Warning in mean.default(X[[i]], ...): argument is not numeric or logical:
## returning NA

## Warning in mean.default(X[[i]], ...): argument is not numeric or logical:
## returning NA
##                   demo eco
## 1 authoritarian regime  NA
## 2     flawed democracy  NA
## 3       full democracy  NA
## 4        hybrid regime  NA
## 5                  n/a  NA
columna=Ifreedom$eco
fila=Ifreedom$demo
(t=table(fila,columna))
##                       columna
## fila                   free moderately free mostly free mostly unfree n/a
##   authoritarian regime    0               9           3            25   5
##   flawed democracy        2              24          12            14   0
##   full democracy          4               5          13             0   0
##   hybrid regime           0              14           2            17   0
##   n/a                     0              10           1             6  13
##                       columna
## fila                   repressed
##   authoritarian regime        12
##   flawed democracy             2
##   full democracy               0
##   hybrid regime                4
##   n/a                          1

Respuesta: la libertad económica SI está relacionada con el nivel de democracia