Skip to content

Commit

Permalink
delete gtExtra
Browse files Browse the repository at this point in the history
  • Loading branch information
ECiardullo committed Nov 18, 2024
1 parent 6c81f71 commit 086f9ca
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 72 deletions.
1 change: 0 additions & 1 deletion R/ARcenso_users.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ library(dplyr)
library(fresh)
library(shinyWidgets)
library(gt)
library(gtExtras)

mytheme <-
create_theme(
Expand Down
141 changes: 70 additions & 71 deletions R/arcenso.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,32 @@
#'
#' @examples arcenso()
arcenso <- function(){

library(shiny)
library(shinydashboard)
library(dplyr)
library(fresh)
library(shinyWidgets)
library(gt)
library(gtExtras)


mytheme <-
create_theme(
adminlte_color(light_blue = "#434C5E"),
adminlte_global(content_bg = "#FFF", box_bg = "#FFFFFF",info_box_bg = "#FFFFFF")
)

#load("info_cuadros_arcenso.RData")

# Header ------------------------------------------------------------------
ui_header <- dashboardHeader(title = "ARcenso consulta", disable = T)

# Side Bar ----------------------------------------------------------------
ui_sidebar <- dashboardSidebar(collapsed = TRUE, sidebarMenu())

# Body --------------------------------------------------------------------

ui_body <- dashboardBody(

use_theme(mytheme),
tabItem(tabName = "consulta",
br(),
Expand All @@ -57,151 +56,151 @@ arcenso <- function(){
inputId = "listas",
label = "Seleccione tabla",
choices = NULL),

), # cierre box

box(
width = 8,status = "info",
h4(textOutput("archivo")),
br(),
gt_output("tablacensal"),
h4(htmlOutput("Fuente"))
) # cierra box

)
) # cierre tab
)

# built -------------------------------------------------------------------

ui <- dashboardPage(header = ui_header,
sidebar = ui_sidebar,
body = ui_body)


# server ------------------------------------------------------------------


server <- function(input, output, session) {


output$banner <- renderImage({

filename <- file.path(paste0(system.file("extdata", package = "arcenso"),"/img"),'arcenso.png')
list(src = filename,
width = 850,
height = 200,
alt = "banner")
}, deleteFile = FALSE)

# OBSER ------------

observeEvent(input$anio, {
geo_filtrada <- info_cuadros_arcenso$Jurisdiccion[info_cuadros_arcenso$anio == input$anio]


updateSelectInput(
session, "geo",
choices = unique(geo_filtrada))

updateSelectInput(session, "tema", choices = NULL)
updateSelectInput(session, "Titulo", choices = NULL)

})


observeEvent(input$geo, {
tema_filtrado <- info_cuadros_arcenso$tema[info_cuadros_arcenso$anio == input$anio & info_cuadros_arcenso$Jurisdiccion == input$geo ]


updateSelectInput(
session, "tema",
choices = unique(tema_filtrado))

updateSelectInput(session, "Titulo", choices = NULL)

})

observeEvent(input$tema, {
listas_filtrado <- info_cuadros_arcenso$Titulo[
info_cuadros_arcenso$anio == input$anio &
info_cuadros_arcenso$Jurisdiccion == input$geo &
info_cuadros_arcenso$tema == input$tema]


updateSelectInput(
session, "listas",
choices = unique(listas_filtrado))

})


# archivo ---------

output$archivo <- renderText({

concepto <- paste(info_cuadros_arcenso %>%
filter(
anio== input$anio,
Jurisdiccion == input$geo,
tema == input$tema,
Titulo == input$listas) %>%
select(Archivo))

})

# tabla ------------


output$tablacensal <- render_gt({


req(input$listas)
req(input$anio)

cuadro <- info_cuadros_arcenso$Archivo[info_cuadros_arcenso$Titulo %in% input$listas]

if(grepl(substr(input$anio,3,4), cuadro)){

path <- paste0(paste0(system.file("extdata", package = "arcenso"),"/"),input$anio,"/")

tabla_censal <- readRDS(paste0(path,cuadro, ".RDS"))

gt(tabla_censal) %>%
opt_interactive(use_compact_mode = TRUE)

} else {
gt(as.data.frame("..."))
}

})

output$Fuente <- renderText({

anio=input$anio

if(req(anio) == 1970){

"Fuente: INDEC, Censo Nacional de Población, Familias y Viviendas 1970."

}
else if(req(anio) == 1980){
"Fuente: INDEC, Censo Nacional de Población y Viviendas 1980"

}



})



}


# ejecutar shiny ----------------------------------------------------------

shinyApp(ui, server)


}

0 comments on commit 086f9ca

Please sign in to comment.