Descripción de la base Column {data-width=500}

Descripción - Extracto de los datos de Gapminder sobre la esperanza de vida, el PIB per cápita y la población por país, el marco principal de datos de gapminder tiene 1704 filas y 6 variables:

Column {data-width=500} Resumen
country continent year lifeExp pop gdpPercap
Afghanistan: 12 Africa :624 Min. :1952 Min. :23.60 Min. :6.001e+04 Min. : 241.2
Albania : 12 Americas:300 1st Qu.:1966 1st Qu.:48.20 1st Qu.:2.794e+06 1st Qu.: 1202.1
Algeria : 12 Asia :396 Median :1980 Median :60.71 Median :7.024e+06 Median : 3531.8
Angola : 12 Europe :360 Mean :1980 Mean :59.47 Mean :2.960e+07 Mean : 7215.3
Argentina : 12 Oceania : 24 3rd Qu.:1993 3rd Qu.:70.85 3rd Qu.:1.959e+07 3rd Qu.: 9325.5
Australia : 12 NA Max. :2007 Max. :82.60 Max. :1.319e+09 Max. :113523.1
(Other) :1632 NA NA NA NA NA
Estructura
tibble [1,704 × 6] (S3: tbl_df/tbl/data.frame)
 $ country  : Factor w/ 142 levels "Afghanistan",..: 1 1 1 1 1 1 1 1 1 1 ...
 $ continent: Factor w/ 5 levels "Africa","Americas",..: 3 3 3 3 3 3 3 3 3 3 ...
 $ year     : int [1:1704] 1952 1957 1962 1967 1972 1977 1982 1987 1992 1997 ...
 $ lifeExp  : num [1:1704] 28.8 30.3 32 34 36.1 ...
 $ pop      : int [1:1704] 8425333 9240934 10267083 11537966 13079460 14880372 12881816 13867957 16317921 22227415 ...
 $ gdpPercap: num [1:1704] 779 821 853 836 740 ...
NULL
Análisis descriptivo Parte 1 Column {data-width=500} Gráfico Interactivo

Column {data-width=500} Gráfico de lineas

Análisis descriptivo Part 2 Row Boxplot
Densidad para LifeExp
Row Barplot
Densidad por continente
---
title: "Gapminder"
author: "Jhoel Calderón"
date: "2024-06-13"
output: 
  flexdashboard::flex_dashboard:
    theme: sandstone
    social: menu
    source_code: embed
    orientation: columns
    vertical_layout: fill
---

```{r setup, include=FALSE}
library(flexdashboard)
library(yaml)
library(knitr)
require(plotly)
library(ggplot2)
require(gganimate)
require(esquisse)
require(gapminder)
library(ggplot2)
library(kableExtra)
library(animation)
gap <- gapminder
```
Descripción de la base
Column {data-width=500}

Descripción
- Extracto de los datos de Gapminder sobre la esperanza de vida, el PIB per cápita y la población por país, el marco principal de datos de gapminder tiene 1704 filas y 6 variables:
  
  - **país**: factor con 142 niveles
- **continente**: factor con 5 niveles
- **año**: va de 1952 a 2007 en incrementos de 5 años
- **lifeExp**: esperanza de vida al nacer, en años
- **pop**: población
- **gdpPercap**: PIB per cápita (dólares de los EE.UU., ajustado a la inflación)

Column {data-width=500}
Resumen
```{r}
resumen <- summary(gap)
kable(resumen) %>% 
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"))
```

Estructura
```{r}
st <- str(gap)
st
```

Análisis descriptivo Parte 1
Column {data-width=500}
Gráfico Interactivo
```{r}
p_interactivo <- ggplot(gap, aes(gdpPercap, lifeExp, size = pop, colour = continent)) +
  geom_point(alpha = 0.5) +
  scale_x_log10()

plot_interactivo <- gap %>% 
  plot_ly(
    x = ~log(gdpPercap),
    y = ~lifeExp,
    size = ~log(pop),
    color = ~continent,
    frame = gap$year,
    alpha = 0.5
  )
```
Column {data-width=500}
Gráfico de lineas


Análisis descriptivo Part 2
Row
Boxplot
```{r}
p <- ggplot(gap, aes(x=continent, y=lifeExp, fill=continent, color=continent)) + 
  geom_boxplot(alpha=0.3) + ggtitle('Boxplot')

ggplotly(p)
```

Densidad para LifeExp
```{r}
binwidth_fd <- 2 * IQR(gap$lifeExp) / length(gap$lifeExp)^(1/3)
k <- ggplot(gap, aes(x = lifeExp)) + 
  geom_histogram(binwidth = binwidth_fd, fill = 'lightseagreen', color = "lightseagreen", alpha = 0.5) + 
  ggtitle('Densidad para lifeExp')
ggplotly(k)
```

Row
Barplot
```{r}
j <- ggplot(gap, aes(x=continent)) + geom_bar(fill=c('lightseagreen','lightskyblue','lightskyblue1',
          'lightskyblue2', 'lightskyblue3')) + ggtitle('Barplot por continente') 

ggplotly(j)
```

Densidad por continente
```{r}
m <- ggplot(gap, aes(x=lifeExp, colour=continent, fill=continent))+
  geom_density(alpha=0.4)
ggplotly(m)
```