Vicente Castro
1 de abril de 2017
This presentation explains the Shiny app you can see in https://viercame.shinyapps.io/week_4_coursera/ The server.R and ui.R code on github can see it in https://github.com/viercame/week4.
Tha data that I use for this analysis correspond to the information of fuel prices in all of the states in Colombia, since jan 2016.
You can get the information from https://www.datos.gov.co/Econom-a-y-Finanzas/Precios-de-Combustibles/7pcy-5vx9
This is the general information of the data.
data <- read.csv("Precios_de_Combustibles.csv", stringsAsFactors = FALSE)
str(data)
## 'data.frame': 150044 obs. of 12 variables:
## $ CodigoDepartamento: int 5 68 68 68 70 70 73 73 76 5 ...
## $ NombreDepartamento: chr "ANTIOQUIA" "SANTANDER" "SANTANDER" "SANTANDER" ...
## $ CodigoMunicipio : int 1 1 307 397 708 1 349 449 1 1 ...
## $ municipio : chr "MEDELLIN" "BUCARAMANGA" "GIRON" "LA PAZ" ...
## $ nombrecomercial : chr "ESSO LA 80" "LA GACELA" "ESTACION DE SERVICIO CHIMITA" "ESTACION DE SERVICIO GERSAN" ...
## $ bandera : chr "MOBIL" "MOBIL" "TERPEL" "TERPEL" ...
## $ direccion : chr "Diagonal 80 No.76-95" "Calle 17 No.19-62" "Kilómetro 1 No. 2 - 119 " "CARRERA 3 No. 5-04" ...
## $ producto : chr "BIODIESEL EXTRA" "BIODIESEL EXTRA" "BIODIESEL EXTRA" "BIODIESEL EXTRA" ...
## $ precio : int 7390 7221 7040 7650 7528 7450 7380 7390 8500 7420 ...
## $ estado : chr "Activo" "Activo" "Activo" "Activo" ...
## $ fecharegistro : chr "02/18/2016 12:00:00 AM" "02/24/2016 12:00:00 AM" "03/02/2016 12:00:00 AM" "04/02/2016 12:00:00 AM" ...
## $ periodo : chr "02/01/2016 12:00:00 AM" "02/01/2016 12:00:00 AM" "02/01/2016 12:00:00 AM" "02/01/2016 12:00:00 AM" ...
The data is constricted day per day. For my analysis we calculated the mean, by month + product + state.
library(plyr)
data$fecharegistro <- as.Date(data$fecharegistro,"%m/%d/%Y")
data$periodo <- as.Date(data$periodo,"%m/%d/%Y")
data.summerised <- ddply(data,c("NombreDepartamento","producto","periodo"), summarise, mean=mean(precio))
str(data.summerised)
## 'data.frame': 1957 obs. of 4 variables:
## $ NombreDepartamento: chr "AMAZONAS" "AMAZONAS" "AMAZONAS" "AMAZONAS" ...
## $ producto : chr "BIODIESEL EXTRA" "BIODIESEL EXTRA" "BIODIESEL EXTRA" "BIODIESEL EXTRA" ...
## $ periodo : Date, format: "2016-01-01" "2016-02-01" ...
## $ mean : num 8071 7330 8275 7745 7556 ...
You can get this kind of plots, using the different options the Shiny app has.
alt text