##Tarea 1 - Gastos municipales por region | Valores en miles de pesos nominales (M$) de cada año.

Pagina 1

Row

Grafico 1 - Programas Recreacionales (M$)

Grafico 2 - Personal Planta (M$)

Row

Grafico 3 - Personal Planta (M$)

Grafico 4 - Programas Recreacionales (M$)

Pagina 2

Row

Grafico 1 - Programas Recreacionales (M$)

Grafico 2 - Personal Planta (M$)

Row

Grafico 3 - Personal Planta (M$)

Grafico 4 - Programas Recreacionales (M$)

---
title: "Tarea1"
author: "Daniel Avello"
date: "`r Sys.Date()`"
output: 
  flexdashboard::flex_dashboard:
    orientation: rows
    social: menu
    source_code: embed
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)

```
##Tarea 1 - Gastos municipales por region | Valores en miles de pesos nominales (M$) de cada año.

Pagina 1
=======================================================================

Row
-----------------------------------------------------------------------

### Grafico 1 - Programas Recreacionales (M$)
```{r}
library(dplyr)
library(data.table)
library(xlsx)
library(readxl)
library(highcharter)
library(flexdashboard)
#lectura datos
setwd("E:/Diplomado2023/Modulo5/tarea")
I <- read_excel("datos_municipales_20231229234026_Arica.xlsx", sheet = 1)
II <- read_excel("datos_municipales_20231225143043_Anto.xlsx", sheet = 1)

I <- rename(I,`ProgramasRecreacionales(M$)` =`BGMAPREC (M$) Gastos Municipales Área de Gestión: Programas Recreacionales`,`ServiciosComunitarios(M$)`=`BGMASCOM (M$) Gastos Municipales Área de Gestión: Servicios Comunitarios`,`PersonalPlanta(M$)`=`IADM72 (M$) Viáticos Personal de Planta y Contrata`)

II <- rename(II,`ProgramasRecreacionales(M$)` =`BGMAPREC (M$) Gastos Municipales Área de Gestión: Programas Recreacionales`,`ServiciosComunitarios(M$)`=`BGMASCOM (M$) Gastos Municipales Área de Gestión: Servicios Comunitarios`,`PersonalPlanta(M$)`=`IADM72 (M$) Viáticos Personal de Planta y Contrata`)
GIA <- 
  hchart(I,type ='scatter',hcaes(x=Año,y=`ProgramasRecreacionales(M$)`,group=factor(MUNICIPIO),color=factor(MUNICIPIO))) %>%
  hc_xAxis(title = "none") %>% 
  hc_yAxis(title = "none") %>%  
  hc_legend(enabled = TRUE,verticalAlign = "top", align = "left", x = 40, y = 0)%>%
  hc_tooltip(shared = FALSE, 
             formatter = JS("function () { return '<b>' + this.series.name + '</b><br/>'  + Highcharts.numberFormat(Math.abs(this.point.y), 0);}")) 
GIA

```
### Grafico 2 - Personal Planta (M$)
```{r}

GIB <- 
  hchart(I,type ='line',hcaes(x=Año,y=`PersonalPlanta(M$)`,group=factor(MUNICIPIO),color=factor(MUNICIPIO))) %>%
  hc_xAxis(title = "none") %>% 
  hc_yAxis(title = "none") %>%  
  hc_legend(enabled = TRUE,verticalAlign = "top", align = "left", x = 40, y = 0)%>%
  hc_tooltip(shared = FALSE, 
             formatter = JS("function () { return '<b>' + this.series.name + '</b><br/>'  + Highcharts.numberFormat(Math.abs(this.point.y), 0);}")) 
GIB
```
Row
-----------------------------------------------------------------------

### Grafico 3 - Personal Planta (M$)
```{r}

GIc <- 
  hchart(I,type ='column',hcaes(x=Año,y=`PersonalPlanta(M$)`,group=factor(MUNICIPIO),color=factor(MUNICIPIO))) %>%
  hc_xAxis(title = "none") %>% 
  hc_yAxis(title = "none") %>%  
  hc_legend(enabled = TRUE,verticalAlign = "top", align = "left", x = 40, y = 0)%>%
  hc_tooltip(shared = FALSE, 
             formatter = JS("function () { return '<b>' + this.series.name + '</b><br/>'  + Highcharts.numberFormat(Math.abs(this.point.y), 0);}")) 
GIc
```
### Grafico 4 - Programas Recreacionales (M$)
```{r}
GId <- 
  hchart(I,type ='column',hcaes(x=Año,y=`ProgramasRecreacionales(M$)`,group=factor(MUNICIPIO),color=factor(MUNICIPIO))) %>%
  hc_xAxis(title = "none") %>% 
  hc_yAxis(title = "none") %>%  
  hc_legend(enabled = TRUE,verticalAlign = "top", align = "left", x = 40, y = 0)%>%
  hc_tooltip(shared = FALSE, 
             formatter = JS("function () { return '<b>' + this.series.name + '</b><br/>'  + Highcharts.numberFormat(Math.abs(this.point.y), 0);}")) 
GId
```
Pagina 2
=======================================================================

Row
-----------------------------------------------------------------------

### Grafico 1 - Programas Recreacionales (M$)
```{r}
GIIA <- 
  hchart(II,type ='scatter',hcaes(x=Año,y=`ProgramasRecreacionales(M$)`,group=factor(MUNICIPIO),color=factor(MUNICIPIO))) %>%
  hc_xAxis(title = "none") %>% 
  hc_yAxis(title = "none") %>%  
  hc_legend(enabled = TRUE,verticalAlign = "top", align = "left", x = 40, y = 0)%>%
  hc_tooltip(shared = FALSE, 
             formatter = JS("function () { return '<b>' + this.series.name + '</b><br/>'  + Highcharts.numberFormat(Math.abs(this.point.y), 0);}")) 
GIIA
```
### Grafico 2 - Personal Planta (M$)
```{r}

GIIB <- 
  hchart(II,type ='line',hcaes(x=Año,y=`PersonalPlanta(M$)`,group=factor(MUNICIPIO),color=factor(MUNICIPIO))) %>%
  hc_xAxis(title = "none") %>% 
  hc_yAxis(title = "none") %>%  
  hc_legend(enabled = TRUE,verticalAlign = "top", align = "left", x = 40, y = 0)%>%
  hc_tooltip(shared = FALSE, 
             formatter = JS("function () { return '<b>' + this.series.name + '</b><br/>'  + Highcharts.numberFormat(Math.abs(this.point.y), 0);}")) 
GIIB
```
Row
-----------------------------------------------------------------------

### Grafico 3 - Personal Planta (M$)
```{r}

GIIc <- 
  hchart(II,type ='column',hcaes(x=Año,y=`PersonalPlanta(M$)`,group=factor(MUNICIPIO),color=factor(MUNICIPIO))) %>%
  hc_xAxis(title = "none") %>% 
  hc_yAxis(title = "none") %>%  
  hc_legend(enabled = TRUE,verticalAlign = "top", align = "left", x = 40, y = 0)%>%
  hc_tooltip(shared = FALSE, 
             formatter = JS("function () { return '<b>' + this.series.name + '</b><br/>'  + Highcharts.numberFormat(Math.abs(this.point.y), 0);}")) 
GIIc
```
### Grafico 4 - Programas Recreacionales (M$)
```{r}
GIId <- 
  hchart(II,type ='column',hcaes(x=Año,y=`ProgramasRecreacionales(M$)`,group=factor(MUNICIPIO),color=factor(MUNICIPIO))) %>%
  hc_xAxis(title = "none") %>% 
  hc_yAxis(title = "none") %>%  
  hc_legend(enabled = TRUE,verticalAlign = "top", align = "left", x = 40, y = 0)%>%
  hc_tooltip(shared = FALSE, 
             formatter = JS("function () { return '<b>' + this.series.name + '</b><br/>'  + Highcharts.numberFormat(Math.abs(this.point.y), 0);}")) 
GIId
```