df <- ivcc
maxi <- max(df$IVCC )
mini <- min(df$IVCC )
incremento <- (maxi-mini)/5
uno <- mini
dos <- mini + incremento
tres <- dos + incremento
cuatro <- tres + incremento
quinto <- cuatro + incremento
sexto <- quinto + incremento
rango <- c(1, 2, 3, 4, 5)
uno <- round(uno, digits = 3)
dos <- round(dos, digits = 3)
primer_rango <- paste(uno, "-", dos)
dos <- round(dos, digits = 3)
tres <- round(tres, digits = 3)
segundo_rango <- paste(dos, "-", tres)
tres <- round(tres, digits = 3)
cuatro <- round(cuatro, digits = 3)
tercer_rango <- paste(tres, "-", cuatro)
cuatro <- round(cuatro, digits = 3)
quinto <- round(quinto, digits = 3)
cuarto_rango <- paste(cuatro, "-", quinto)
quinto <- round(quinto, digits = 3)
sexto <- round(sexto, digits = 3)
quinto_rango <- paste(quinto, "-", sexto)
rango <- c(1,2,3,4,5)
intervalos <- c(primer_rango, segundo_rango , tercer_rango , cuarto_rango , quinto_rango )
df2 <- data.frame(rango, intervalos)
df$IVCC_rango <- ifelse(df$IVCC >= uno & df$IVCC < dos , 1,
ifelse(df$IVCC >= dos & df$IVCC < tres , 2,
ifelse(df$IVCC >= tres & df$IVCC < cuatro , 3,
ifelse(df$IVCC >= cuatro & df$IVCC < quinto ,4,
ifelse(df$IVCC >= quinto ,5,"")))))
df$IVCC_rango_cat <- ifelse(df$IVCC_rango == "1" , "muy bajo nivel - IVCC",
ifelse(df$IVCC_rango == "2" , "bajo nivel - IVCC",
ifelse(df$IVCC_rango == "3" , "moderado nivel - IVCC",
ifelse(df$IVCC_rango == "4" , "alto nivel - IVCC",
ifelse(df$IVCC_rango == "5" , "muy alto nivel - IVCC","")))))
info <- read_xlsx("demografia.xlsx")
df <- merge(df,info,by="codigo")
df <- df[,c(1,13:18,2:12)]
write_xlsx(df,"ivcc.xlsx")
datatable(df, extensions = 'Buttons', escape = FALSE, rownames = TRUE,
options = list(dom = 'Bfrtip',
buttons = list('colvis', list(extend = 'collection',
buttons = list(
list(extend='copy'),
list(extend='excel',
filename = 'IVCC'),
list(extend='pdf',
filename= 'IVCC')),
text = 'Download')), scrollX = TRUE))