library(rio)
library(ggplot2)
library(ggcorrplot)
library(reticulate)
## 
## Attaching package: 'reticulate'
## The following object is masked from 'package:rio':
## 
##     import
use_python("C:/Users/Charles/anaconda3")
rm(list = ls())
inefilink= "https://github.com/bocchienjoyer/MaGODllanes/raw/main/ProyectoMagaDeidad/datita/year_mod_obras_long.pkl"
pd<-import("pandas")
inefistats<- pd$read_pickle(inefilink)
str(inefistats)
## 'data.frame':    78 obs. of  4 variables:
##  $ ano                : num  2006 2006 2007 2007 2008 ...
##  $ modalidad_ejecucion: chr  "Administración directa" "Contrata" "Administración directa" "Contrata" ...
##  $ variable           : chr  "npry_puntajeirimean" "npry_puntajeirimean" "npry_puntajeirimean" "npry_puntajeirimean" ...
##  $ value              : num  41.1 46.5 35.6 40 34 ...
##  - attr(*, "pandas.index")=RangeIndex(start=0, stop=78, step=1)
graf1= ggplot(data=inefistats,
               aes(x=ano,y=value,color=modalidad_ejecucion)) + geom_smooth(se=TRUE, method = "loess")+ scale_color_manual(values = c("Administración directa"= "red", "Contrata"= "yellow", "Otros"="blue")) + theme_light() +
  labs(title = "Evolución de la ineficiencia de las obras según modalidad",
       x="Año",
       y="Puntaje promdio IRI",
       color="Modalidad de ejecución")
    scale_y_log10(labels=scales::comma)
## <ScaleContinuousPosition>
##  Range:  
##  Limits:    0 --    1
graf1 +    
    geom_smooth()  + 
    facet_grid(variable~.,scales = 'free_y') 
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'