Cargar libreria

library(readr)

Importar los datos

datos <- read.csv("https://raw.githubusercontent.com/rpizarrog/probabilidad-y-estad-stica/master/practicas%20R/unidad%202/alumnos.deportes.2020.csv")

datos
##     X   nombres sexo futbol basquetbol voleybol atletismo ajedrez tenis
## 1   1       Ana    F  FALSE      FALSE    FALSE     FALSE   FALSE FALSE
## 2   2   Antonio    M  FALSE      FALSE    FALSE     FALSE   FALSE FALSE
## 3   3   Aracely    F  FALSE      FALSE    FALSE     FALSE   FALSE  TRUE
## 4   4    Carmen    F  FALSE       TRUE    FALSE     FALSE   FALSE FALSE
## 5   5   Eduardo    M   TRUE      FALSE    FALSE     FALSE   FALSE FALSE
## 6   6   Ernesto    M  FALSE       TRUE    FALSE     FALSE   FALSE FALSE
## 7   7    Gabino    M  FALSE       TRUE    FALSE     FALSE   FALSE FALSE
## 8   8   Gerardo    M   TRUE      FALSE     TRUE     FALSE   FALSE  TRUE
## 9   9    Javier    M  FALSE       TRUE    FALSE     FALSE   FALSE FALSE
## 10 10  Jeorgina    F  FALSE       TRUE    FALSE     FALSE   FALSE FALSE
## 11 11      Juan    M   TRUE      FALSE    FALSE      TRUE   FALSE FALSE
## 12 12      Lalo    M  FALSE      FALSE     TRUE     FALSE   FALSE FALSE
## 13 13     Laura    F  FALSE       TRUE    FALSE     FALSE   FALSE FALSE
## 14 14      Lucy    F   TRUE      FALSE     TRUE      TRUE   FALSE FALSE
## 15 15      Luis    M  FALSE      FALSE     TRUE     FALSE   FALSE FALSE
## 16 16     Luisa    F  FALSE      FALSE    FALSE     FALSE   FALSE FALSE
## 17 17    Lupita    F   TRUE       TRUE    FALSE     FALSE   FALSE FALSE
## 18 18 Margarita    F  FALSE       TRUE    FALSE      TRUE   FALSE FALSE
## 19 19 Margarito    M  FALSE      FALSE    FALSE     FALSE   FALSE  TRUE
## 20 20     Maria    F  FALSE       TRUE    FALSE     FALSE   FALSE FALSE
## 21 21      Memo    M   TRUE      FALSE    FALSE     FALSE    TRUE FALSE
## 22 22     Oscar    M  FALSE      FALSE    FALSE     FALSE   FALSE FALSE
## 23 23      Paco    M   TRUE      FALSE     TRUE     FALSE    TRUE FALSE
## 24 24  Patricia    F   TRUE      FALSE    FALSE      TRUE   FALSE FALSE
## 25 25      Paty    F   TRUE       TRUE    FALSE     FALSE   FALSE FALSE
## 26 26      Raul    M   TRUE      FALSE    FALSE     FALSE   FALSE FALSE
## 27 27  Romualdo    M   TRUE      FALSE    FALSE     FALSE   FALSE FALSE
## 28 28   Rosario    F  FALSE      FALSE    FALSE     FALSE   FALSE FALSE
## 29 29     Rubén    M   TRUE      FALSE    FALSE     FALSE   FALSE FALSE
## 30 30  Salvador    M   TRUE      FALSE    FALSE      TRUE   FALSE FALSE
## 31 31    Sandra    F  FALSE      FALSE    FALSE     FALSE   FALSE FALSE
## 32 32    Sandro    M  FALSE      FALSE    FALSE     FALSE   FALSE  TRUE
## 33 33      Saul    M   TRUE      FALSE     TRUE     FALSE   FALSE FALSE
## 34 34      Yuri    F   TRUE      FALSE    FALSE     FALSE   FALSE FALSE
## 35 35    Arturo    M  FALSE      FALSE    FALSE     FALSE   FALSE FALSE
## 36 36  Angélica    F   TRUE       TRUE     TRUE     FALSE   FALSE FALSE
## 37 37   Arnulfo    M  FALSE      FALSE     TRUE     FALSE   FALSE FALSE
## 38 38      Bety    F   TRUE       TRUE    FALSE     FALSE   FALSE FALSE
## 39 39    Carlos    M   TRUE      FALSE    FALSE     FALSE   FALSE FALSE
## 40 40 Dagoberto    M  FALSE      FALSE     TRUE     FALSE   FALSE FALSE
## 41 41      Dany    F   TRUE       TRUE    FALSE     FALSE   FALSE FALSE
## 42 42     Dalia    F   TRUE      FALSE    FALSE     FALSE   FALSE FALSE
## 43 43     Efren    M   TRUE      FALSE    FALSE      TRUE   FALSE FALSE
## 44 44 Ernestina    F   TRUE      FALSE     TRUE     FALSE    TRUE FALSE
## 45 45  Fernando    M   TRUE      FALSE    FALSE      TRUE   FALSE FALSE
## 46 46    Fabián    M  FALSE       TRUE     TRUE     FALSE   FALSE FALSE
## 47 47  Fernanda    F  FALSE      FALSE    FALSE     FALSE   FALSE FALSE
## 48 48  Gabriela    F  FALSE      FALSE    FALSE     FALSE   FALSE FALSE
## 49 49   Gabriel    M   TRUE      FALSE    FALSE     FALSE   FALSE FALSE
## 50 50    Guille    F   TRUE      FALSE    FALSE     FALSE    TRUE FALSE
## 51 51     Jorge    M   TRUE       TRUE    FALSE     FALSE   FALSE FALSE
## 52 52   Lorenzo    M   TRUE      FALSE     TRUE     FALSE   FALSE FALSE
## 53 53   Mikaela    F  FALSE       TRUE    FALSE     FALSE   FALSE FALSE
## 54 54    Miguel    M   TRUE       TRUE    FALSE     FALSE   FALSE FALSE
## 55 55   Marcela    F  FALSE      FALSE    FALSE      TRUE   FALSE FALSE
## 56 56   Orlando    M   TRUE      FALSE    FALSE     FALSE   FALSE FALSE
## 57 57    Otilia    F   TRUE      FALSE    FALSE      TRUE   FALSE FALSE
## 58 58     Pedro    M   TRUE       TRUE    FALSE     FALSE   FALSE FALSE
## 59 59     Perla    F  FALSE      FALSE    FALSE     FALSE   FALSE FALSE
## 60 60    Raquel    F   TRUE       TRUE    FALSE     FALSE   FALSE FALSE
## 61 61    Susana    F  FALSE      FALSE    FALSE     FALSE   FALSE FALSE
## 62 62     Sandy    F  FALSE       TRUE    FALSE     FALSE   FALSE FALSE
## 63 63    Sotelo    M  FALSE      FALSE     TRUE      TRUE   FALSE FALSE
## 64 64  Tiburcio    M  FALSE      FALSE    FALSE      TRUE   FALSE FALSE
## 65 65    Teresa    F  FALSE      FALSE    FALSE     FALSE   FALSE FALSE
## 66 66    Walter    F   TRUE       TRUE    FALSE     FALSE   FALSE FALSE
## 67 67   Xóchitl    F  FALSE       TRUE     TRUE      TRUE    TRUE FALSE

Cantidad de datos

n <- nrow(datos)

##Conjunto tanto de hombres y mujeres con la funcion subset()

hombres <- subset(datos, sexo =='M')
mujeres <- subset(datos, sexo =='F')

hombres
##     X   nombres sexo futbol basquetbol voleybol atletismo ajedrez tenis
## 2   2   Antonio    M  FALSE      FALSE    FALSE     FALSE   FALSE FALSE
## 5   5   Eduardo    M   TRUE      FALSE    FALSE     FALSE   FALSE FALSE
## 6   6   Ernesto    M  FALSE       TRUE    FALSE     FALSE   FALSE FALSE
## 7   7    Gabino    M  FALSE       TRUE    FALSE     FALSE   FALSE FALSE
## 8   8   Gerardo    M   TRUE      FALSE     TRUE     FALSE   FALSE  TRUE
## 9   9    Javier    M  FALSE       TRUE    FALSE     FALSE   FALSE FALSE
## 11 11      Juan    M   TRUE      FALSE    FALSE      TRUE   FALSE FALSE
## 12 12      Lalo    M  FALSE      FALSE     TRUE     FALSE   FALSE FALSE
## 15 15      Luis    M  FALSE      FALSE     TRUE     FALSE   FALSE FALSE
## 19 19 Margarito    M  FALSE      FALSE    FALSE     FALSE   FALSE  TRUE
## 21 21      Memo    M   TRUE      FALSE    FALSE     FALSE    TRUE FALSE
## 22 22     Oscar    M  FALSE      FALSE    FALSE     FALSE   FALSE FALSE
## 23 23      Paco    M   TRUE      FALSE     TRUE     FALSE    TRUE FALSE
## 26 26      Raul    M   TRUE      FALSE    FALSE     FALSE   FALSE FALSE
## 27 27  Romualdo    M   TRUE      FALSE    FALSE     FALSE   FALSE FALSE
## 29 29     Rubén    M   TRUE      FALSE    FALSE     FALSE   FALSE FALSE
## 30 30  Salvador    M   TRUE      FALSE    FALSE      TRUE   FALSE FALSE
## 32 32    Sandro    M  FALSE      FALSE    FALSE     FALSE   FALSE  TRUE
## 33 33      Saul    M   TRUE      FALSE     TRUE     FALSE   FALSE FALSE
## 35 35    Arturo    M  FALSE      FALSE    FALSE     FALSE   FALSE FALSE
## 37 37   Arnulfo    M  FALSE      FALSE     TRUE     FALSE   FALSE FALSE
## 39 39    Carlos    M   TRUE      FALSE    FALSE     FALSE   FALSE FALSE
## 40 40 Dagoberto    M  FALSE      FALSE     TRUE     FALSE   FALSE FALSE
## 43 43     Efren    M   TRUE      FALSE    FALSE      TRUE   FALSE FALSE
## 45 45  Fernando    M   TRUE      FALSE    FALSE      TRUE   FALSE FALSE
## 46 46    Fabián    M  FALSE       TRUE     TRUE     FALSE   FALSE FALSE
## 49 49   Gabriel    M   TRUE      FALSE    FALSE     FALSE   FALSE FALSE
## 51 51     Jorge    M   TRUE       TRUE    FALSE     FALSE   FALSE FALSE
## 52 52   Lorenzo    M   TRUE      FALSE     TRUE     FALSE   FALSE FALSE
## 54 54    Miguel    M   TRUE       TRUE    FALSE     FALSE   FALSE FALSE
## 56 56   Orlando    M   TRUE      FALSE    FALSE     FALSE   FALSE FALSE
## 58 58     Pedro    M   TRUE       TRUE    FALSE     FALSE   FALSE FALSE
## 63 63    Sotelo    M  FALSE      FALSE     TRUE      TRUE   FALSE FALSE
## 64 64  Tiburcio    M  FALSE      FALSE    FALSE      TRUE   FALSE FALSE
hombres <- subset(datos, sexo =='M')
mujeres <- subset(datos, sexo =='F')

mujeres
##     X   nombres sexo futbol basquetbol voleybol atletismo ajedrez tenis
## 1   1       Ana    F  FALSE      FALSE    FALSE     FALSE   FALSE FALSE
## 3   3   Aracely    F  FALSE      FALSE    FALSE     FALSE   FALSE  TRUE
## 4   4    Carmen    F  FALSE       TRUE    FALSE     FALSE   FALSE FALSE
## 10 10  Jeorgina    F  FALSE       TRUE    FALSE     FALSE   FALSE FALSE
## 13 13     Laura    F  FALSE       TRUE    FALSE     FALSE   FALSE FALSE
## 14 14      Lucy    F   TRUE      FALSE     TRUE      TRUE   FALSE FALSE
## 16 16     Luisa    F  FALSE      FALSE    FALSE     FALSE   FALSE FALSE
## 17 17    Lupita    F   TRUE       TRUE    FALSE     FALSE   FALSE FALSE
## 18 18 Margarita    F  FALSE       TRUE    FALSE      TRUE   FALSE FALSE
## 20 20     Maria    F  FALSE       TRUE    FALSE     FALSE   FALSE FALSE
## 24 24  Patricia    F   TRUE      FALSE    FALSE      TRUE   FALSE FALSE
## 25 25      Paty    F   TRUE       TRUE    FALSE     FALSE   FALSE FALSE
## 28 28   Rosario    F  FALSE      FALSE    FALSE     FALSE   FALSE FALSE
## 31 31    Sandra    F  FALSE      FALSE    FALSE     FALSE   FALSE FALSE
## 34 34      Yuri    F   TRUE      FALSE    FALSE     FALSE   FALSE FALSE
## 36 36  Angélica    F   TRUE       TRUE     TRUE     FALSE   FALSE FALSE
## 38 38      Bety    F   TRUE       TRUE    FALSE     FALSE   FALSE FALSE
## 41 41      Dany    F   TRUE       TRUE    FALSE     FALSE   FALSE FALSE
## 42 42     Dalia    F   TRUE      FALSE    FALSE     FALSE   FALSE FALSE
## 44 44 Ernestina    F   TRUE      FALSE     TRUE     FALSE    TRUE FALSE
## 47 47  Fernanda    F  FALSE      FALSE    FALSE     FALSE   FALSE FALSE
## 48 48  Gabriela    F  FALSE      FALSE    FALSE     FALSE   FALSE FALSE
## 50 50    Guille    F   TRUE      FALSE    FALSE     FALSE    TRUE FALSE
## 53 53   Mikaela    F  FALSE       TRUE    FALSE     FALSE   FALSE FALSE
## 55 55   Marcela    F  FALSE      FALSE    FALSE      TRUE   FALSE FALSE
## 57 57    Otilia    F   TRUE      FALSE    FALSE      TRUE   FALSE FALSE
## 59 59     Perla    F  FALSE      FALSE    FALSE     FALSE   FALSE FALSE
## 60 60    Raquel    F   TRUE       TRUE    FALSE     FALSE   FALSE FALSE
## 61 61    Susana    F  FALSE      FALSE    FALSE     FALSE   FALSE FALSE
## 62 62     Sandy    F  FALSE       TRUE    FALSE     FALSE   FALSE FALSE
## 65 65    Teresa    F  FALSE      FALSE    FALSE     FALSE   FALSE FALSE
## 66 66    Walter    F   TRUE       TRUE    FALSE     FALSE   FALSE FALSE
## 67 67   Xóchitl    F  FALSE       TRUE     TRUE      TRUE    TRUE FALSE

##Frecuencias de Hombres y Mujeres

table(datos$sexo)
## 
##  F  M 
## 33 34

##Frecuencias relativas de Hombres y Mujeres mediante la funcion prop.table(table()).

round(prop.table(table(datos$sexo)),4)
## 
##      F      M 
## 0.4925 0.5075
round(prop.table(table(datos$sexo)),4) * 100
## 
##     F     M 
## 49.25 50.75

##Pregunta 1: ¿Cual es la probabilidad de que un alumno sea hombre? 50.75% ##Pregunta 2: ¿Cual es la probabilidad de que un alumno sea mujer? 49.25% ##Conjunto Fútbol

futbol <- subset(datos, futbol  == TRUE)

futbol
##     X   nombres sexo futbol basquetbol voleybol atletismo ajedrez tenis
## 5   5   Eduardo    M   TRUE      FALSE    FALSE     FALSE   FALSE FALSE
## 8   8   Gerardo    M   TRUE      FALSE     TRUE     FALSE   FALSE  TRUE
## 11 11      Juan    M   TRUE      FALSE    FALSE      TRUE   FALSE FALSE
## 14 14      Lucy    F   TRUE      FALSE     TRUE      TRUE   FALSE FALSE
## 17 17    Lupita    F   TRUE       TRUE    FALSE     FALSE   FALSE FALSE
## 21 21      Memo    M   TRUE      FALSE    FALSE     FALSE    TRUE FALSE
## 23 23      Paco    M   TRUE      FALSE     TRUE     FALSE    TRUE FALSE
## 24 24  Patricia    F   TRUE      FALSE    FALSE      TRUE   FALSE FALSE
## 25 25      Paty    F   TRUE       TRUE    FALSE     FALSE   FALSE FALSE
## 26 26      Raul    M   TRUE      FALSE    FALSE     FALSE   FALSE FALSE
## 27 27  Romualdo    M   TRUE      FALSE    FALSE     FALSE   FALSE FALSE
## 29 29     Rubén    M   TRUE      FALSE    FALSE     FALSE   FALSE FALSE
## 30 30  Salvador    M   TRUE      FALSE    FALSE      TRUE   FALSE FALSE
## 33 33      Saul    M   TRUE      FALSE     TRUE     FALSE   FALSE FALSE
## 34 34      Yuri    F   TRUE      FALSE    FALSE     FALSE   FALSE FALSE
## 36 36  Angélica    F   TRUE       TRUE     TRUE     FALSE   FALSE FALSE
## 38 38      Bety    F   TRUE       TRUE    FALSE     FALSE   FALSE FALSE
## 39 39    Carlos    M   TRUE      FALSE    FALSE     FALSE   FALSE FALSE
## 41 41      Dany    F   TRUE       TRUE    FALSE     FALSE   FALSE FALSE
## 42 42     Dalia    F   TRUE      FALSE    FALSE     FALSE   FALSE FALSE
## 43 43     Efren    M   TRUE      FALSE    FALSE      TRUE   FALSE FALSE
## 44 44 Ernestina    F   TRUE      FALSE     TRUE     FALSE    TRUE FALSE
## 45 45  Fernando    M   TRUE      FALSE    FALSE      TRUE   FALSE FALSE
## 49 49   Gabriel    M   TRUE      FALSE    FALSE     FALSE   FALSE FALSE
## 50 50    Guille    F   TRUE      FALSE    FALSE     FALSE    TRUE FALSE
## 51 51     Jorge    M   TRUE       TRUE    FALSE     FALSE   FALSE FALSE
## 52 52   Lorenzo    M   TRUE      FALSE     TRUE     FALSE   FALSE FALSE
## 54 54    Miguel    M   TRUE       TRUE    FALSE     FALSE   FALSE FALSE
## 56 56   Orlando    M   TRUE      FALSE    FALSE     FALSE   FALSE FALSE
## 57 57    Otilia    F   TRUE      FALSE    FALSE      TRUE   FALSE FALSE
## 58 58     Pedro    M   TRUE       TRUE    FALSE     FALSE   FALSE FALSE
## 60 60    Raquel    F   TRUE       TRUE    FALSE     FALSE   FALSE FALSE
## 66 66    Walter    F   TRUE       TRUE    FALSE     FALSE   FALSE FALSE

##Frecuencias de personas en Fútbol

table(datos$futbol)
## 
## FALSE  TRUE 
##    34    33

##Frecuencias relativas del conjunto Fútbol

round(prop.table(table(datos$futbol)),4)
## 
##  FALSE   TRUE 
## 0.5075 0.4925
round(prop.table(table(datos$futbol)),4) * 100
## 
## FALSE  TRUE 
## 50.75 49.25

##Pregunta 3: ¿Cuál es la probabilidad de que un alumno juegue fútbol? 49.25% ##Conjunto Basquetbol

basquetbol <- subset(datos, basquetbol  == TRUE)

basquetbol
##     X   nombres sexo futbol basquetbol voleybol atletismo ajedrez tenis
## 4   4    Carmen    F  FALSE       TRUE    FALSE     FALSE   FALSE FALSE
## 6   6   Ernesto    M  FALSE       TRUE    FALSE     FALSE   FALSE FALSE
## 7   7    Gabino    M  FALSE       TRUE    FALSE     FALSE   FALSE FALSE
## 9   9    Javier    M  FALSE       TRUE    FALSE     FALSE   FALSE FALSE
## 10 10  Jeorgina    F  FALSE       TRUE    FALSE     FALSE   FALSE FALSE
## 13 13     Laura    F  FALSE       TRUE    FALSE     FALSE   FALSE FALSE
## 17 17    Lupita    F   TRUE       TRUE    FALSE     FALSE   FALSE FALSE
## 18 18 Margarita    F  FALSE       TRUE    FALSE      TRUE   FALSE FALSE
## 20 20     Maria    F  FALSE       TRUE    FALSE     FALSE   FALSE FALSE
## 25 25      Paty    F   TRUE       TRUE    FALSE     FALSE   FALSE FALSE
## 36 36  Angélica    F   TRUE       TRUE     TRUE     FALSE   FALSE FALSE
## 38 38      Bety    F   TRUE       TRUE    FALSE     FALSE   FALSE FALSE
## 41 41      Dany    F   TRUE       TRUE    FALSE     FALSE   FALSE FALSE
## 46 46    Fabián    M  FALSE       TRUE     TRUE     FALSE   FALSE FALSE
## 51 51     Jorge    M   TRUE       TRUE    FALSE     FALSE   FALSE FALSE
## 53 53   Mikaela    F  FALSE       TRUE    FALSE     FALSE   FALSE FALSE
## 54 54    Miguel    M   TRUE       TRUE    FALSE     FALSE   FALSE FALSE
## 58 58     Pedro    M   TRUE       TRUE    FALSE     FALSE   FALSE FALSE
## 60 60    Raquel    F   TRUE       TRUE    FALSE     FALSE   FALSE FALSE
## 62 62     Sandy    F  FALSE       TRUE    FALSE     FALSE   FALSE FALSE
## 66 66    Walter    F   TRUE       TRUE    FALSE     FALSE   FALSE FALSE
## 67 67   Xóchitl    F  FALSE       TRUE     TRUE      TRUE    TRUE FALSE

##Frecuencias de personas en basquetbol

table(datos$basquetbol )
## 
## FALSE  TRUE 
##    45    22

##Frecuencias relativas del conjunto basquetbol

round(prop.table(table(datos$basquetbol )),4)
## 
##  FALSE   TRUE 
## 0.6716 0.3284
round(prop.table(table(datos$basquetbol )),4) * 100
## 
## FALSE  TRUE 
## 67.16 32.84

##Pregunta 4: ¿Cuál es la probabilidad de que un alumno juegue basquetbol ? 32.84% ##Conjunto voleybol

voleybol  <- subset(datos, voleybol   == TRUE)

voleybol 
##     X   nombres sexo futbol basquetbol voleybol atletismo ajedrez tenis
## 8   8   Gerardo    M   TRUE      FALSE     TRUE     FALSE   FALSE  TRUE
## 12 12      Lalo    M  FALSE      FALSE     TRUE     FALSE   FALSE FALSE
## 14 14      Lucy    F   TRUE      FALSE     TRUE      TRUE   FALSE FALSE
## 15 15      Luis    M  FALSE      FALSE     TRUE     FALSE   FALSE FALSE
## 23 23      Paco    M   TRUE      FALSE     TRUE     FALSE    TRUE FALSE
## 33 33      Saul    M   TRUE      FALSE     TRUE     FALSE   FALSE FALSE
## 36 36  Angélica    F   TRUE       TRUE     TRUE     FALSE   FALSE FALSE
## 37 37   Arnulfo    M  FALSE      FALSE     TRUE     FALSE   FALSE FALSE
## 40 40 Dagoberto    M  FALSE      FALSE     TRUE     FALSE   FALSE FALSE
## 44 44 Ernestina    F   TRUE      FALSE     TRUE     FALSE    TRUE FALSE
## 46 46    Fabián    M  FALSE       TRUE     TRUE     FALSE   FALSE FALSE
## 52 52   Lorenzo    M   TRUE      FALSE     TRUE     FALSE   FALSE FALSE
## 63 63    Sotelo    M  FALSE      FALSE     TRUE      TRUE   FALSE FALSE
## 67 67   Xóchitl    F  FALSE       TRUE     TRUE      TRUE    TRUE FALSE

##Frecuencias de personas en voleybol

table(datos$voleybol  )
## 
## FALSE  TRUE 
##    53    14

##Frecuencias relativas del conjunto voleybol

round(prop.table(table(datos$voleybol  )),4)
## 
## FALSE  TRUE 
## 0.791 0.209
round(prop.table(table(datos$voleybol  )),4) * 100
## 
## FALSE  TRUE 
##  79.1  20.9

##Pregunta 5: ¿Cuál es la probabilidad de que un alumno juegue voleybol? 20.9% ##Conjunto atletismo

atletismo   <- subset(datos, atletismo    == TRUE)

atletismo 
##     X   nombres sexo futbol basquetbol voleybol atletismo ajedrez tenis
## 11 11      Juan    M   TRUE      FALSE    FALSE      TRUE   FALSE FALSE
## 14 14      Lucy    F   TRUE      FALSE     TRUE      TRUE   FALSE FALSE
## 18 18 Margarita    F  FALSE       TRUE    FALSE      TRUE   FALSE FALSE
## 24 24  Patricia    F   TRUE      FALSE    FALSE      TRUE   FALSE FALSE
## 30 30  Salvador    M   TRUE      FALSE    FALSE      TRUE   FALSE FALSE
## 43 43     Efren    M   TRUE      FALSE    FALSE      TRUE   FALSE FALSE
## 45 45  Fernando    M   TRUE      FALSE    FALSE      TRUE   FALSE FALSE
## 55 55   Marcela    F  FALSE      FALSE    FALSE      TRUE   FALSE FALSE
## 57 57    Otilia    F   TRUE      FALSE    FALSE      TRUE   FALSE FALSE
## 63 63    Sotelo    M  FALSE      FALSE     TRUE      TRUE   FALSE FALSE
## 64 64  Tiburcio    M  FALSE      FALSE    FALSE      TRUE   FALSE FALSE
## 67 67   Xóchitl    F  FALSE       TRUE     TRUE      TRUE    TRUE FALSE

##Frecuencias de personas en atletismo

table(datos$atletismo   )
## 
## FALSE  TRUE 
##    55    12

##Frecuencias relativas del conjunto atletismo

round(prop.table(table(datos$atletismo   )),4)
## 
##  FALSE   TRUE 
## 0.8209 0.1791
round(prop.table(table(datos$atletismo   )),4) * 100
## 
## FALSE  TRUE 
## 82.09 17.91

##Pregunta 6: ¿Cuál es la probabilidad de que un alumno practique atletismo? 17.91% ##Conjunto tenis

tenis    <- subset(datos, tenis     == TRUE)

tenis  
##     X   nombres sexo futbol basquetbol voleybol atletismo ajedrez tenis
## 3   3   Aracely    F  FALSE      FALSE    FALSE     FALSE   FALSE  TRUE
## 8   8   Gerardo    M   TRUE      FALSE     TRUE     FALSE   FALSE  TRUE
## 19 19 Margarito    M  FALSE      FALSE    FALSE     FALSE   FALSE  TRUE
## 32 32    Sandro    M  FALSE      FALSE    FALSE     FALSE   FALSE  TRUE

##Frecuencias de personas en tenis

table(datos$tenis    )
## 
## FALSE  TRUE 
##    63     4

##Frecuencias relativas del conjunto tenis

round(prop.table(table(datos$tenis    )),4)
## 
##  FALSE   TRUE 
## 0.9403 0.0597
round(prop.table(table(datos$tenis    )),4) * 100
## 
## FALSE  TRUE 
## 94.03  5.97

##Pregunta 7: ¿Cuál es la probabilidad de que un alumno practique tenis? 5.97% ##Conjunto ajedrez

ajedrez    <- subset(datos, ajedrez     == TRUE)

ajedrez 
##     X   nombres sexo futbol basquetbol voleybol atletismo ajedrez tenis
## 21 21      Memo    M   TRUE      FALSE    FALSE     FALSE    TRUE FALSE
## 23 23      Paco    M   TRUE      FALSE     TRUE     FALSE    TRUE FALSE
## 44 44 Ernestina    F   TRUE      FALSE     TRUE     FALSE    TRUE FALSE
## 50 50    Guille    F   TRUE      FALSE    FALSE     FALSE    TRUE FALSE
## 67 67   Xóchitl    F  FALSE       TRUE     TRUE      TRUE    TRUE FALSE

##Frecuencias de personas en ajedrez

table(datos$ajedrez    )
## 
## FALSE  TRUE 
##    62     5

##Frecuencias relativas del conjunto ajedrez

round(prop.table(table(datos$ajedrez    )),4)
## 
##  FALSE   TRUE 
## 0.9254 0.0746
round(prop.table(table(datos$ajedrez    )),4) * 100
## 
## FALSE  TRUE 
## 92.54  7.46

##Pregunta 8: ¿Cuál es la probabilidad de que un alumno juegue ajedrez? 7.46% ##Unión de conjuntos ##Unión de fútbol y basquetbol

futUbas <- union(futbol$nombres, basquetbol$nombres)
futUbas
##  [1] "Eduardo"   "Gerardo"   "Juan"      "Lucy"      "Lupita"    "Memo"     
##  [7] "Paco"      "Patricia"  "Paty"      "Raul"      "Romualdo"  "Rubén"    
## [13] "Salvador"  "Saul"      "Yuri"      "Angélica"  "Bety"      "Carlos"   
## [19] "Dany"      "Dalia"     "Efren"     "Ernestina" "Fernando"  "Gabriel"  
## [25] "Guille"    "Jorge"     "Lorenzo"   "Miguel"    "Orlando"   "Otilia"   
## [31] "Pedro"     "Raquel"    "Walter"    "Carmen"    "Ernesto"   "Gabino"   
## [37] "Javier"    "Jeorgina"  "Laura"     "Margarita" "Maria"     "Fabián"   
## [43] "Mikaela"   "Sandy"     "Xóchitl"

##Cálculo de probabilidad por frecuencia relativa

cat("Hay ", length(futUbas), " alumnos que juegan fútbol o basquetbol de un total de ",n)
## Hay  45  alumnos que juegan fútbol o basquetbol de un total de  67
prob.futUbas <- length(futUbas) / n 

cat("* ¿Cuál es la probabilidad de que existan alumnos que jueguen fútbol o basquetbol?
", prob.futUbas)
## * ¿Cuál es la probabilidad de que existan alumnos que jueguen fútbol o basquetbol?
##  0.6716418

##Intersección de conjuntos de futbol y basquetbol

futIbas <- intersect(futbol$nombres, basquetbol$nombres)
futIbas
##  [1] "Lupita"   "Paty"     "Angélica" "Bety"     "Dany"     "Jorge"   
##  [7] "Miguel"   "Pedro"    "Raquel"   "Walter"

##Cálculo de probabilidad por frecuencia relativa de la intersección entre futbol y basquetbol

cat("Hay ", length(futIbas), " alumnos que juegan fútbol y que también  juegan basquetbol de un total de ",n)
## Hay  10  alumnos que juegan fútbol y que también  juegan basquetbol de un total de  67
prob.futIbas <- length(futIbas) / n 

cat("¿Cuántos alumnos hay que juegan fútbol y basquetbol?", prob.futIbas)
## ¿Cuántos alumnos hay que juegan fútbol y basquetbol? 0.1492537

##Probabilidad por medio de la ley de adicion ##Prob(A ∪ B) = Prob(A) + Prob(B) - Prob(A ∩ B)

prob.futbol <- prop.table(table(datos$futbol))
prob.basquetbol <- prop.table(table(datos$basquetbol))

prob.futbol <- prob.futbol[2] 
prob.basquetbol <- prob.basquetbol[2]

prob.futbol
##      TRUE 
## 0.4925373
prob.basquetbol
##      TRUE 
## 0.3283582
as.numeric(prob.futbol)
## [1] 0.4925373
as.numeric(prob.basquetbol)
## [1] 0.3283582
as.numeric(prob.futIbas)
## [1] 0.1492537
prob.futUbas <- as.numeric(prob.futbol) + as.numeric(prob.basquetbol) - as.numeric(prob.futIbas)

prob.futUbas
## [1] 0.6716418
cat("* ¿Cuál es la probabilidad de que existan alumnos que jueguen fútbol o basquetbol?
", prob.futUbas)
## * ¿Cuál es la probabilidad de que existan alumnos que jueguen fútbol o basquetbol?
##  0.6716418

##Unión de tenis y ajedrez

tenUaje <- union(tenis$nombres, ajedrez$nombres)
tenUaje
## [1] "Aracely"   "Gerardo"   "Margarito" "Sandro"    "Memo"      "Paco"     
## [7] "Ernestina" "Guille"    "Xóchitl"

##Cálculo de probabilidad por frecuencia relativa

cat("Hay ", length(tenUaje), " alumnos que juegan tenis o ajedrez de un total de ",n)
## Hay  9  alumnos que juegan tenis o ajedrez de un total de  67
prob.tenUaje <- length(tenUaje) / n 

cat("* ¿Cuál es la probabilidad de que existan alumnos que jueguen tenis o ajedrez?
", prob.tenUaje)
## * ¿Cuál es la probabilidad de que existan alumnos que jueguen tenis o ajedrez?
##  0.1343284

##Intersección de conjuntos de tenis y ajedrez

tenIaje <- intersect(tenis$nombres, ajedrez$nombres)
tenIaje
## character(0)

##Cálculo de probabilidad por frecuencia relativa de la intersección entre tenis y ajedrez

cat("Hay ", length(tenIaje), " alumnos que juegan tenis y que también  juegan ajedrez de un total de ",n)
## Hay  0  alumnos que juegan tenis y que también  juegan ajedrez de un total de  67
prob.tenIaje <- length(tenIaje) / n 

cat("¿Cuántos alumnos hay que juegan tenis y ajedrez?", prob.futIbas)
## ¿Cuántos alumnos hay que juegan tenis y ajedrez? 0.1492537

##Probabilidad por medio de la ley de adicion ##Prob(A ∪ B) = Prob(A) + Prob(B) - Prob(A ∩ B)

prob.tenis <- prop.table(table(datos$tenis))
prob.ajedrez <- prop.table(table(datos$ajedrez))

prob.tenis <- prob.tenis[2] 
prob.ajedrez <- prob.ajedrez[2]

prob.tenis
##       TRUE 
## 0.05970149
prob.ajedrez
##       TRUE 
## 0.07462687
as.numeric(prob.tenis)
## [1] 0.05970149
as.numeric(prob.ajedrez)
## [1] 0.07462687
as.numeric(prob.tenIaje)
## [1] 0
prob.tenUaje <- as.numeric(prob.tenis) + as.numeric(prob.ajedrez) - as.numeric(prob.tenIaje)

prob.tenUaje
## [1] 0.1343284
cat("* ¿Cuál es la probabilidad de que existan alumnos que jueguen tenis o ajedrez?
", prob.tenUaje)
## * ¿Cuál es la probabilidad de que existan alumnos que jueguen tenis o ajedrez?
##  0.1343284

##Unión de atletismo y voleybol

atleUvol <- union(atletismo$nombres, voleybol$nombres)
atleUvol
##  [1] "Juan"      "Lucy"      "Margarita" "Patricia"  "Salvador"  "Efren"    
##  [7] "Fernando"  "Marcela"   "Otilia"    "Sotelo"    "Tiburcio"  "Xóchitl"  
## [13] "Gerardo"   "Lalo"      "Luis"      "Paco"      "Saul"      "Angélica" 
## [19] "Arnulfo"   "Dagoberto" "Ernestina" "Fabián"    "Lorenzo"

##Cálculo de probabilidad por frecuencia relativa

cat("Hay ", length(atleUvol), " alumnos que juegan atletismo o voleybol de un total de ",n)
## Hay  23  alumnos que juegan atletismo o voleybol de un total de  67
prob.atleUvol <- length(atleUvol) / n 

cat("* ¿Cuál es la probabilidad de que existan alumnos que jueguen atletismo o voleybol?
", prob.atleUvol)
## * ¿Cuál es la probabilidad de que existan alumnos que jueguen atletismo o voleybol?
##  0.3432836

##Intersección de conjuntos de atletismo y voleybol

atleIvol <- intersect(atletismo$nombres, voleybol$nombres)
atleIvol
## [1] "Lucy"    "Sotelo"  "Xóchitl"

##Cálculo de probabilidad por frecuencia relativa de la intersección entre atletismo y voleybol

cat("Hay ", length(atleIvol), " alumnos que juegan atletismo y que también  juegan voleybol de un total de ",n)
## Hay  3  alumnos que juegan atletismo y que también  juegan voleybol de un total de  67
prob.atleIvol <- length(atleIvol) / n 

cat("¿Cuántos alumnos hay que juegan atletismo y voleybol?", prob.atleIvol)
## ¿Cuántos alumnos hay que juegan atletismo y voleybol? 0.04477612

##Probabilidad por medio de la ley de adicion ##Prob(A ∪ B) = Prob(A) + Prob(B) - Prob(A ∩ B)

prob.atletismo <- prop.table(table(datos$atletismo))
prob.voleybol <- prop.table(table(datos$voleybol))

prob.atletismo <- prob.atletismo[2] 
prob.voleybol <- prob.voleybol[2]

prob.atletismo
##      TRUE 
## 0.1791045
prob.voleybol
##      TRUE 
## 0.2089552
as.numeric(prob.atletismo)
## [1] 0.1791045
as.numeric(prob.voleybol)
## [1] 0.2089552
as.numeric(prob.atleIvol)
## [1] 0.04477612
prob.atleUvol <- as.numeric(prob.atletismo) + as.numeric(prob.voleybol) - as.numeric(prob.atleIvol)

prob.atleUvol
## [1] 0.3432836
cat("* ¿Cuál es la probabilidad de que existan alumnos que jueguen atletismo o voleybol?
", prob.atleUvol)
## * ¿Cuál es la probabilidad de que existan alumnos que jueguen atletismo o voleybol?
##  0.3432836

##Unión de voleybol y futbol

volUfut <- union(voleybol$nombres, futbol$nombres)
volUfut
##  [1] "Gerardo"   "Lalo"      "Lucy"      "Luis"      "Paco"      "Saul"     
##  [7] "Angélica"  "Arnulfo"   "Dagoberto" "Ernestina" "Fabián"    "Lorenzo"  
## [13] "Sotelo"    "Xóchitl"   "Eduardo"   "Juan"      "Lupita"    "Memo"     
## [19] "Patricia"  "Paty"      "Raul"      "Romualdo"  "Rubén"     "Salvador" 
## [25] "Yuri"      "Bety"      "Carlos"    "Dany"      "Dalia"     "Efren"    
## [31] "Fernando"  "Gabriel"   "Guille"    "Jorge"     "Miguel"    "Orlando"  
## [37] "Otilia"    "Pedro"     "Raquel"    "Walter"

##Cálculo de probabilidad por frecuencia relativa

cat("Hay ", length(volUfut), " alumnos que juegan voleybol o futbol de un total de ",n)
## Hay  40  alumnos que juegan voleybol o futbol de un total de  67
prob.volUfut <- length(volUfut) / n 

cat("* ¿Cuál es la probabilidad de que existan alumnos que jueguen fútbol o basquetbol?
", prob.volUfut)
## * ¿Cuál es la probabilidad de que existan alumnos que jueguen fútbol o basquetbol?
##  0.5970149

##Intersección de conjuntos de voleybol y futbol

volIfut <- intersect(voleybol$nombres, futbol$nombres)
volIfut
## [1] "Gerardo"   "Lucy"      "Paco"      "Saul"      "Angélica"  "Ernestina"
## [7] "Lorenzo"

##Cálculo de probabilidad por frecuencia relativa de la intersección entre voleybol y futbol

cat("Hay ", length(volIfut), " alumnos que juegan voleybol y que también  juegan futbol de un total de ",n)
## Hay  7  alumnos que juegan voleybol y que también  juegan futbol de un total de  67
prob.volIfut <- length(volIfut) / n 

cat("¿Cuántos alumnos hay que juegan fútbol y basquetbol?", prob.volIfut)
## ¿Cuántos alumnos hay que juegan fútbol y basquetbol? 0.1044776

##Probabilidad por medio de la ley de adicion ##Prob(A ∪ B) = Prob(A) + Prob(B) - Prob(A ∩ B)

prob.futbol <- prop.table(table(datos$futbol))
prob.voleybol <- prop.table(table(datos$voleybol))

prob.futbol <- prob.futbol[2] 
prob.voleybol <- prob.voleybol[2]

prob.futbol
##      TRUE 
## 0.4925373
prob.voleybol
##      TRUE 
## 0.2089552
as.numeric(prob.futbol)
## [1] 0.4925373
as.numeric(prob.voleybol)
## [1] 0.2089552
as.numeric(prob.volIfut)
## [1] 0.1044776
prob.volUfut <- as.numeric(prob.futbol) + as.numeric(prob.voleybol) - as.numeric(prob.volIfut)

prob.volUfut
## [1] 0.5970149
cat("* ¿Cuál es la probabilidad de que existan alumnos que jueguen voleybol o futbol ?
", prob.volUfut)
## * ¿Cuál es la probabilidad de que existan alumnos que jueguen voleybol o futbol ?
##  0.5970149

##Unión de basquetbol y voleybol

basUvol <- union(voleybol$nombres, basquetbol$nombres)
basUvol
##  [1] "Gerardo"   "Lalo"      "Lucy"      "Luis"      "Paco"      "Saul"     
##  [7] "Angélica"  "Arnulfo"   "Dagoberto" "Ernestina" "Fabián"    "Lorenzo"  
## [13] "Sotelo"    "Xóchitl"   "Carmen"    "Ernesto"   "Gabino"    "Javier"   
## [19] "Jeorgina"  "Laura"     "Lupita"    "Margarita" "Maria"     "Paty"     
## [25] "Bety"      "Dany"      "Jorge"     "Mikaela"   "Miguel"    "Pedro"    
## [31] "Raquel"    "Sandy"     "Walter"

##Cálculo de probabilidad por frecuencia relativa

cat("Hay ", length(basUvol), " alumnos que juegan basquetbol o voleybol de un total de ",n)
## Hay  33  alumnos que juegan basquetbol o voleybol de un total de  67
prob.basUvol <- length(basUvol) / n 

cat("* ¿Cuál es la probabilidad de que existan alumnos que jueguen basquetbol o voleybol?
", prob.basUvol)
## * ¿Cuál es la probabilidad de que existan alumnos que jueguen basquetbol o voleybol?
##  0.4925373

##Intersección de conjuntos de basquetbol y voleybol

basIvol <- intersect(voleybol$nombres, basquetbol$nombres)
basIvol
## [1] "Angélica" "Fabián"   "Xóchitl"

##Cálculo de probabilidad por frecuencia relativa de la intersección entre basquetbol y voleybol

cat("Hay ", length(basIvol), " alumnos que juegan basquetbol y que también  juegan voleybol de un total de ",n)
## Hay  3  alumnos que juegan basquetbol y que también  juegan voleybol de un total de  67
prob.basIvol <- length(basIvol) / n 

cat("¿Cuántos alumnos hay que juegan basquetbol y voleybol?", prob.basIvol)
## ¿Cuántos alumnos hay que juegan basquetbol y voleybol? 0.04477612

##Probabilidad por medio de la ley de adicion ##Prob(A ∪ B) = Prob(A) + Prob(B) - Prob(A ∩ B)

prob.basquetbol <- prop.table(table(datos$basquetbol))
prob.voleybol <- prop.table(table(datos$voleybol))

prob.basquetbol <- prob.basquetbol[2] 
prob.voleybol <- prob.voleybol[2]

prob.basquetbol
##      TRUE 
## 0.3283582
prob.voleybol
##      TRUE 
## 0.2089552
as.numeric(prob.basquetbol)
## [1] 0.3283582
as.numeric(prob.voleybol)
## [1] 0.2089552
as.numeric(prob.basIvol)
## [1] 0.04477612
prob.basUvol <- as.numeric(prob.basquetbol) + as.numeric(prob.voleybol) - as.numeric(prob.basIvol)

prob.basUvol
## [1] 0.4925373
cat("* ¿Cuál es la probabilidad de que existan alumnos que jueguen basquetbol o voleybol ?
", prob.basUvol)
## * ¿Cuál es la probabilidad de que existan alumnos que jueguen basquetbol o voleybol ?
##  0.4925373

##Tablas cruzadas ##futbol y basquetbol

table(datos$futbol, datos$basquetbol)
##        
##         FALSE TRUE
##   FALSE    22   12
##   TRUE     23   10

##Frecuencias utilizando tablas cruzadas

tabla.cruzada <- table(datos$futbol, datos$basquetbol, dnn = c('fútbol','basquetbol'))

tabla.cruzada
##        basquetbol
## fútbol  FALSE TRUE
##   FALSE    22   12
##   TRUE     23   10
tabla.cruzada.s <- rbind(tabla.cruzada, apply(tabla.cruzada,2,sum))

tabla.cruzada.s <- cbind(tabla.cruzada.s, apply(tabla.cruzada.s,1,sum))

tabla.cruzada.s
##       FALSE TRUE   
## FALSE    22   12 34
## TRUE     23   10 33
##          45   22 67

##Interpretación de la tabla cruzada frecuencias ##Hay 34 alumnos que juegan futbol; renglón 2 de un total de 67 ##Hay 22 personas que juegan basquetbol columna 2 de un total de 67 ##Hay 10 personas que juegan futbol y basquetbol al mismo tiempo de un total de 67 ##Cálculo de probabilidades utilizando tablas cruzadas

prob.tabla.cruzada <- round(prop.table(table(datos$futbol, datos$basquetbol, dnn = c('fútbol','basquetbol'))),4)

prob.tabla.cruzada
##        basquetbol
## fútbol   FALSE   TRUE
##   FALSE 0.3284 0.1791
##   TRUE  0.3433 0.1493
prob.tabla.cruzada <- rbind(prob.tabla.cruzada,apply(prob.tabla.cruzada,2,sum))
                            
prob.tabla.cruzada <- cbind(prob.tabla.cruzada, apply(prob.tabla.cruzada,1,sum)) 

prob.tabla.cruzada
##        FALSE   TRUE       
## FALSE 0.3284 0.1791 0.5075
## TRUE  0.3433 0.1493 0.4926
##       0.6717 0.3284 1.0001

##Interpretación de la tabla cruzada probabilidades ##34 alumnos que juegan futbol que representan el 49.26% del 100% ##Hay 22 personas que juegan basquetbol que representan el 32.84% del 100% ##Hay 10c personas que juegan futbol y basquetbol al mismo tiempo que representan el 14.93% del 100% o del total de alumnos ###Tenis o Ajedrez

table(datos$tenis, datos$ajedrez)
##        
##         FALSE TRUE
##   FALSE    58    5
##   TRUE      4    0

##Frecuencias utilizando tablas cruzadas

tabla.cruzada <- table(datos$tenis, datos$ajedrez, dnn = c('tenis','ajedrez'))

tabla.cruzada
##        ajedrez
## tenis   FALSE TRUE
##   FALSE    58    5
##   TRUE      4    0
tabla.cruzada.s <- rbind(tabla.cruzada, apply(tabla.cruzada,2,sum))

tabla.cruzada.s <- cbind(tabla.cruzada.s, apply(tabla.cruzada.s,1,sum))

tabla.cruzada.s
##       FALSE TRUE   
## FALSE    58    5 63
## TRUE      4    0  4
##          62    5 67

##Interpretación de la tabla cruzada frecuencias ##Hay 5 alumnos que juegan ajedrez; renglón 2 de un total de 67 ##Hay 4 personas que juegan tenis columna 2 de un total de 67 ##Hay 0 personas que juegan futbol y basquetbol al mismo tiempo de un total de 67 ##Cálculo de probabilidades utilizando tablas cruzadas

prob.tabla.cruzada <- round(prop.table(table(datos$tenis, datos$ajedrez, dnn = c('tenis','ajedrez'))),4)

prob.tabla.cruzada
##        ajedrez
## tenis    FALSE   TRUE
##   FALSE 0.8657 0.0746
##   TRUE  0.0597 0.0000
prob.tabla.cruzada <- rbind(prob.tabla.cruzada,apply(prob.tabla.cruzada,2,sum))
                            
prob.tabla.cruzada <- cbind(prob.tabla.cruzada, apply(prob.tabla.cruzada,1,sum)) 

prob.tabla.cruzada
##        FALSE   TRUE       
## FALSE 0.8657 0.0746 0.9403
## TRUE  0.0597 0.0000 0.0597
##       0.9254 0.0746 1.0000

##Interpretación de la tabla cruzada probabilidades ##5 alumnos que juegan ajedrez que representan el 7.46% del 100% ##Hay 4 personas que juegan tenis que representan el 5.97% del 100% ##Hay 58 personas que juegan no juegan ni ajedrez ni tenis al mismo tiempo que representan el 86.56% del 100% o del total de alumnos ##Atletismo o Voleybol

table(datos$atletismo, datos$voleybol)
##        
##         FALSE TRUE
##   FALSE    44   11
##   TRUE      9    3

##Frecuencias utilizando tablas cruzadas

tabla.cruzada <- table(datos$atletismo, datos$voleybol, dnn = c('atletismo','voleybol '))

tabla.cruzada
##          voleybol 
## atletismo FALSE TRUE
##     FALSE    44   11
##     TRUE      9    3
tabla.cruzada.s <- rbind(tabla.cruzada, apply(tabla.cruzada,2,sum))

tabla.cruzada.s <- cbind(tabla.cruzada.s, apply(tabla.cruzada.s,1,sum))

tabla.cruzada.s
##       FALSE TRUE   
## FALSE    44   11 55
## TRUE      9    3 12
##          53   14 67

##Interpretación de la tabla cruzada frecuencias ##Hay 12 alumnos que juegan atletismo; renglón 2 de un total de 67 ##Hay 14 personas que juegan voleyvol columna 2 de un total de 67 ##Hay 3 personas que juegan voleybol y atletismo al mismo tiempo de un total de 67 ##Cálculo de probabilidades utilizando tablas cruzadas

prob.tabla.cruzada <- round(prop.table(table(datos$atletismo, datos$voleybol, dnn = c('atletismo','voleybol'))),4)

prob.tabla.cruzada
##          voleybol
## atletismo  FALSE   TRUE
##     FALSE 0.6567 0.1642
##     TRUE  0.1343 0.0448
prob.tabla.cruzada <- rbind(prob.tabla.cruzada,apply(prob.tabla.cruzada,2,sum))
                            
prob.tabla.cruzada <- cbind(prob.tabla.cruzada, apply(prob.tabla.cruzada,1,sum)) 

prob.tabla.cruzada
##        FALSE   TRUE       
## FALSE 0.6567 0.1642 0.8209
## TRUE  0.1343 0.0448 0.1791
##       0.7910 0.2090 1.0000

##Interpretación de la tabla cruzada probabilidades ##12 alumnos que juegan atletismo que representan el 17.91% del 100% ##Hay 14 personas que juegan voleybol que representan el 20.89% del 100% ##Hay 3 personas que juegan boleybol y atletismo al mismo tiempo que representan el 4.47% del 100% o del total de alumnos ##Hay 41 personas que no juegan ni voleybol ni atletismo y representan el 61.19% ##Voleybol o futbol

table(datos$voleybol, datos$futbol)
##        
##         FALSE TRUE
##   FALSE    27   26
##   TRUE      7    7

##Frecuencias utilizando tablas cruzadas

tabla.cruzada <- table(datos$voleybol, datos$futbol, dnn = c('voleybol','futbol '))

tabla.cruzada
##         futbol 
## voleybol FALSE TRUE
##    FALSE    27   26
##    TRUE      7    7
tabla.cruzada.s <- rbind(tabla.cruzada, apply(tabla.cruzada,2,sum))

tabla.cruzada.s <- cbind(tabla.cruzada.s, apply(tabla.cruzada.s,1,sum))

tabla.cruzada.s
##       FALSE TRUE   
## FALSE    27   26 53
## TRUE      7    7 14
##          34   33 67

##Interpretación de la tabla cruzada frecuencias ##Hay 33 alumnos que juegan futbol; renglón 2 de un total de 67 ##Hay 14 personas que juegan voleyvol columna 2 de un total de 67 ##Hay 7 personas que juegan voleybol y atletismo al mismo tiempo de un total de 67 ##Cálculo de probabilidades utilizando tablas cruzadas

prob.tabla.cruzada <- round(prop.table(table(datos$voleybol, datos$futbol, dnn = c('voleybol','futbol'))),4)

prob.tabla.cruzada
##         futbol
## voleybol  FALSE   TRUE
##    FALSE 0.4030 0.3881
##    TRUE  0.1045 0.1045
prob.tabla.cruzada <- rbind(prob.tabla.cruzada,apply(prob.tabla.cruzada,2,sum))
                            
prob.tabla.cruzada <- cbind(prob.tabla.cruzada, apply(prob.tabla.cruzada,1,sum)) 

prob.tabla.cruzada
##        FALSE   TRUE       
## FALSE 0.4030 0.3881 0.7911
## TRUE  0.1045 0.1045 0.2090
##       0.5075 0.4926 1.0001

##Interpretación de la tabla cruzada probabilidades ##33 alumnos que juegan futbol que representan el 49.25% del 100% ##Hay 14 personas que juegan voleybol que representan el 20.89% del 100% ##Hay 7 personas que juegan voleybol y futbol al mismo tiempo que representan el 10.44% del 100% o del total de alumnos ##Hay 20 personas que no juegan ni voleybol ni futbol y representan el 29.85% ##basquetbol o voleybol

table(datos$basquetbol, datos$voleybol)
##        
##         FALSE TRUE
##   FALSE    34   11
##   TRUE     19    3

##Frecuencias utilizando tablas cruzadas

tabla.cruzada <- table(datos$basquetbol, datos$voleybol, dnn = c('basquetbol','voleybol '))

tabla.cruzada
##           voleybol 
## basquetbol FALSE TRUE
##      FALSE    34   11
##      TRUE     19    3
tabla.cruzada.s <- rbind(tabla.cruzada, apply(tabla.cruzada,2,sum))

tabla.cruzada.s <- cbind(tabla.cruzada.s, apply(tabla.cruzada.s,1,sum))

tabla.cruzada.s
##       FALSE TRUE   
## FALSE    34   11 45
## TRUE     19    3 22
##          53   14 67

##Interpretación de la tabla cruzada frecuencias ##Hay 22 alumnos que juegan basquetbol; columna 2 de un total de 67 ##Hay 14 personas que juegan voleyvol renglon 2 de un total de 67 ##Hay 3 personas que juegan basquetbol y voleybol al mismo tiempo de un total de 67 ##Cálculo de probabilidades utilizando tablas cruzadas

prob.tabla.cruzada <- round(prop.table(table(datos$basquetbol, datos$voleybol, dnn = c('basquetbol','voleybol'))),4)

prob.tabla.cruzada
##           voleybol
## basquetbol  FALSE   TRUE
##      FALSE 0.5075 0.1642
##      TRUE  0.2836 0.0448
prob.tabla.cruzada <- rbind(prob.tabla.cruzada,apply(prob.tabla.cruzada,2,sum))
                            
prob.tabla.cruzada <- cbind(prob.tabla.cruzada, apply(prob.tabla.cruzada,1,sum)) 

prob.tabla.cruzada
##        FALSE   TRUE       
## FALSE 0.5075 0.1642 0.6717
## TRUE  0.2836 0.0448 0.3284
##       0.7911 0.2090 1.0001

##Interpretación de la tabla cruzada probabilidades ##22 alumnos que juegan basquetbol que representan el 32.83% del 100% ##Hay 14 personas que juegan voleybol que representan el 20.89% del 100% ##Hay 3 personas que juegan voleybol y basquetbol al mismo tiempo que representan el 4.4% del 100% o del total de alumnos ##Hay 31 personas que no juegan ni voleybol ni basquet y representan el 46.26%