---
title: "HTML notebook"
author: "Lucio Cornejo"
date: "`r Sys.Date()`"
output: 
  html_notebook:
    toc: true
    toc_float: 
      collapsed: false
    # Escoge un theme que te guste: default, cerulean, journal, flatly, darkly, readable, spacelab, united, cosmo, lumen, paper, sandstone, simplex, and yeti
    theme: cerulean 
    # Escoge el resaltado de código que prefieras: default, tango, pygments, kate, monochrome, espresso, zenburn, haddock, breezedark, and textmate. Pass null to prevent syntax highlighting.
    hightlight: tango 
editor_options: 
  chunk_output_type: inline
---

```{r cargar-data, include=FALSE}
# Base de datos usada para crear el data frame "temperaturas":
# nottem 
# (Average Monthly Temperatures at Nottingham, 1920-1939)

## Data frame que vamos a cargar vía un archivo Excel
# temperaturas <- data.frame(
#                     anio = c(1920,1921,1922,1923,1924,1925,1926,1927,1928,1929,1930,1931,1932,1933,1934,1935,1936,1937,1938,1939),
#                     enero = c(40.6,44.2,37.5,41.8,39.3,40.0,39.2,39.4,40.8,34.8,41.6,37.1,42.4,36.2,39.4,40.0,37.3,40.8,42.1,39.4),
#                     febrero = c(40.8,39.8,38.7,40.1,37.5,40.5,43.4,38.5,41.1,31.3,37.1,38.4,38.4,39.3,38.2,42.6,35.0,41.0,41.2,40.9),
#                     marzo = c(44.4,45.1,39.5,42.9,38.3,40.8,43.4,45.3,42.8,41.0,41.2,38.4,40.3,44.5,40.4,43.5,44.0,38.4,47.3,42.4),
#                     abril = c(46.7,47.0,42.1,45.8,45.5,45.1,48.9,47.1,47.3,43.9,46.9,46.5,44.6,48.7,46.9,47.1,43.9,47.4,46.6,47.8),
#                     mayo = c(54.1,54.1,55.7,49.2,53.2,53.8,50.6,51.7,50.9,53.1,51.2,53.5,50.9,54.2,53.4,50.0,52.7,54.1,52.4,52.4),
#                     junio = c(58.5,58.7,57.8,52.7,57.7,59.4,56.8,55.0,56.4,56.9,60.4,58.4,57.0,60.8,59.6,60.5,58.6,58.6,59.0,58.0),
#                     julio = c(57.7,66.3,56.8,64.2,60.8,63.5,62.5,60.4,62.2,62.5,60.1,60.6,62.1,65.5,66.5,64.6,60.0,61.4,59.6,60.7),
#                     agosto = c(56.4,59.9,54.3,59.6,58.2,61.0,62.0,60.5,60.5,60.3,61.6,58.2,63.5,64.9,60.4,64.0,61.1,61.8,60.4,61.8),
#                     setiembre = c(54.3,57.0,54.3,54.4,56.4,53.0,57.5,54.7,55.4,59.8,57.0,53.8,56.3,60.1,59.2,56.8,58.1,56.3,57.0,58.2),
#                     octubre = c(50.5,54.2,47.1,49.2,49.8,50.0,46.7,50.3,50.2,49.2,50.9,46.6,47.3,50.2,51.2,48.6,49.6,50.9,50.7,46.7),
#                     noviembre = c(42.9,39.7,41.8,36.3,44.4,38.1,41.6,42.3,43.0,42.9,43.0,45.5,43.6,42.1,42.8,44.2,41.6,41.4,47.8,46.6),
#                     diciembre = c(39.8,42.8,41.7,37.6,43.6,36.3,39.8,35.2,37.3,41.9,38.8,40.6,41.8,35.8,45.8,36.4,41.3,37.1,39.2,37.8)
# )

# GUARDAR ARCHIVO EXCEL EN MISMA CARPETA QUE ESTE DOCUMENTO RMD
temperaturas <- readxl::read_excel(file.choose())
```

```{r escoger-anio,echo=FALSE}
# Años posibles: 1920 a 1939
anio <- 1920    #######################
```

## Año `r anio` 

### Temperaturas mensuales promedio en _Nottingham_

<center>
```{r diagrama-de-barras,echo = FALSE}
temperatura_anual <- temperaturas[temperaturas$anio == anio,]
temperatura_anual <- unlist(temperatura_anual)[-1]

barplot(height = temperatura_anual, names = 1:12,
       xlab = "Mes", ylab = "Temperatura promedio", col = "skyblue")
```
</center>

### Conclusiones

```{r mes-max-min-temperatura, include=FALSE}
mes_max_temperatura <- colnames(temperaturas)[1+which(temperatura_anual == max(temperatura_anual))]
mes_min_temperatura <- colnames(temperaturas)[1+which(temperatura_anual == min(temperatura_anual))]
```

- En `r mes_max_temperatura`, se registró la temperatura promedio mensual máxima
del año `r anio`.

- En `r mes_min_temperatura`, se registró la temperatura promedio mensual mínima
del año `r anio`.

<br>
