1.Carga el archivo suministrado titanic.cvs

library(readr)
library(dplyr)
## Warning: package 'dplyr' was built under R version 4.1.3
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(plotly)
## Warning: package 'plotly' was built under R version 4.1.3
## Loading required package: ggplot2
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
library(ggplot2)
titanic <- read.csv("C:/Users/Usuario/Downloads/titanic (1).csv")
DT::datatable(titanic)
sapply(titanic, function(x) sum(is.na(x)))
## PassengerId    Survived      Pclass        Name         Sex         Age 
##           0           0           0           0           0         177 
##       SibSp       Parch      Ticket        Fare       Cabin    Embarked 
##           0           0           0           0           0           0

2.Calcular y mostrar el valor de la media y la mediana de las edades de las personas que viajaban en el barco y sobrevivieron

Sobrevivieron= titanic %>% filter(Survived=="1")
Sobrevivieron$Age[is.na(Sobrevivieron$Age)]<-28
DT::datatable(Sobrevivieron)
mean(x = Sobrevivieron$Age)
## [1] 28.29143
median(x = Sobrevivieron$Age)
## [1] 28

3.Mostrar la cantidad de personas que viajaban en el barco en cada una de las tres clases.

Clases<-titanic %>% count(Pclass)
Clases
##   Pclass   n
## 1      1 216
## 2      2 184
## 3      3 491

4.Mostrar la cantidad de personas que viajaban en el barco en cada una de las tres clases dicriminando por sobrevivientes y no sobrevivientes.

titanic %>% group_by (Pclass,Survived) %>% summarise(count_sales = n())
## `summarise()` has grouped output by 'Pclass'. You can override using the
## `.groups` argument.
## # A tibble: 6 x 3
## # Groups:   Pclass [3]
##   Pclass Survived count_sales
##    <int>    <int>       <int>
## 1      1        0          80
## 2      1        1         136
## 3      2        0          97
## 4      2        1          87
## 5      3        0         372
## 6      3        1         119

5.Calular y mostrar el valor del tiquete más ecónomico, más costoso y el valor promedio

min(titanic$Fare)
## [1] 0
max(titanic$Fare)
## [1] 512.3292
mean(titanic$Fare)
## [1] 32.20421
Precio<- select(titanic,Fare)
DT::datatable(Precio)
summary(Precio)
##       Fare       
##  Min.   :  0.00  
##  1st Qu.:  7.91  
##  Median : 14.45  
##  Mean   : 32.20  
##  3rd Qu.: 31.00  
##  Max.   :512.33

6.Realice un diagrama de barras (barplot) que permita visualizar la cantidad de personas por género.

ggplot(titanic, aes(Sex))+
  geom_bar(fill=10)

7.Realice un diagrama de barras (barplot) que permita visualizar la cantidad de personas por tipo de tiquete.

titanic %>% ggplot(aes(x=Pclass)) + geom_bar(stat = "count")

8.Realice un diagrama de caja (boxplot) con los datos de las edades. ¿Cuál es su interpretación a lovisualizado en el gráfico?

Edades<- select(titanic,Age)
DT::datatable(Edades)
summary(Edades)
##       Age       
##  Min.   : 0.42  
##  1st Qu.:20.12  
##  Median :28.00  
##  Mean   :29.70  
##  3rd Qu.:38.00  
##  Max.   :80.00  
##  NA's   :177
Edades_Box=ggplot(titanic, aes(y=Age))+geom_boxplot(fill=30)
ggplotly(Edades_Box)
## Warning: Removed 177 rows containing non-finite values (stat_boxplot).

9.Para cada una de las variables muestre el consolidado de la siguiente información: valor mínimo, primer cuartil, promedio, tercer cuartil y valor máximo. Recuerde se requiere para cada variable.

summary(titanic)
##   PassengerId       Survived          Pclass          Name          
##  Min.   :  1.0   Min.   :0.0000   Min.   :1.000   Length:891        
##  1st Qu.:223.5   1st Qu.:0.0000   1st Qu.:2.000   Class :character  
##  Median :446.0   Median :0.0000   Median :3.000   Mode  :character  
##  Mean   :446.0   Mean   :0.3838   Mean   :2.309                     
##  3rd Qu.:668.5   3rd Qu.:1.0000   3rd Qu.:3.000                     
##  Max.   :891.0   Max.   :1.0000   Max.   :3.000                     
##                                                                     
##      Sex                 Age            SibSp           Parch       
##  Length:891         Min.   : 0.42   Min.   :0.000   Min.   :0.0000  
##  Class :character   1st Qu.:20.12   1st Qu.:0.000   1st Qu.:0.0000  
##  Mode  :character   Median :28.00   Median :0.000   Median :0.0000  
##                     Mean   :29.70   Mean   :0.523   Mean   :0.3816  
##                     3rd Qu.:38.00   3rd Qu.:1.000   3rd Qu.:0.0000  
##                     Max.   :80.00   Max.   :8.000   Max.   :6.0000  
##                     NA's   :177                                     
##     Ticket               Fare           Cabin             Embarked        
##  Length:891         Min.   :  0.00   Length:891         Length:891        
##  Class :character   1st Qu.:  7.91   Class :character   Class :character  
##  Mode  :character   Median : 14.45   Mode  :character   Mode  :character  
##                     Mean   : 32.20                                        
##                     3rd Qu.: 31.00                                        
##                     Max.   :512.33                                        
## 

Referencias:

-Hadley Wickham , Romain François , Lionel Henry , Kirill Müller, contar observaciones por grupo https://dplyr.tidyverse.org/reference/count.html