From 4bf5e6108959343336ac77ab032cbbd9a03fd425 Mon Sep 17 00:00:00 2001 From: plablo09 Date: Thu, 20 May 2021 13:51:12 -0500 Subject: [PATCH] =?UTF-8?q?Documentaci=C3=B3n.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- R/app_server.R | 2 ++ R/app_ui.R | 12 +++++------- R/mod_DBSelector.R | 12 ++++-------- R/mod_bar.R | 11 +++++------ R/mod_graficas.R | 31 +++++++++++++++---------------- 5 files changed, 31 insertions(+), 37 deletions(-) diff --git a/R/app_server.R b/R/app_server.R index 2d26636..742e084 100644 --- a/R/app_server.R +++ b/R/app_server.R @@ -1,4 +1,6 @@ #' The application server-side +#' Define la estructura general de la aplicación +#' sidebar, paneles, etc #' #' @param input,output,session Internal parameters for {shiny}. #' DO NOT REMOVE. diff --git a/R/app_ui.R b/R/app_ui.R index 9aca20c..776b7b4 100644 --- a/R/app_ui.R +++ b/R/app_ui.R @@ -1,4 +1,6 @@ #' The application User-Interface +#' Los elementos de la UI que corresponden a la estructura +#' del server side #' #' @param request Internal parameter for `{shiny}`. #' DO NOT REMOVE. @@ -7,18 +9,16 @@ app_ui <- function(request) { shinydashboard::dashboardPage( - # title = 'Visualizador de Datos de Incidentes Viales - SEMOVI', - # skin = 'green', shinydashboard::dashboardHeader( title = "Visualizador de Datos de Incidentes Viales - SEMOVI"), shinydashboard::dashboardSidebar(shinydashboard::sidebarMenuOutput("menu")), shinydashboard::dashboardBody(shinydashboard::tabItems( - ##############Introduccion########## + ### Introduccion ### shinydashboard::tabItem(tabName = "intro", mod_introPageUI_ui("introPageUI_ui_1") ), shinydashboard::tabItem(tabName = "bd", mod_infoBdUI_ui("infoBdUI_ui_1")), - ########### Visualizador################# + ### Visualizador ### shinydashboard::tabItem( tabName = "visualizador", fluidPage( @@ -32,7 +32,7 @@ app_ui <- function(request) { ) ) ), - ######## Actualizacion######## + ### Actualizacion ### shinydashboard::tabItem(tabName = "actualiza", mod_csvFileUI_ui("csvFileUI_ui", label = "Selecciona un CSV"), DT::dataTableOutput("tabla") @@ -41,8 +41,6 @@ app_ui <- function(request) { tagList( # Leave this function for adding external resources golem_add_external_resources(), - # List the first level UI elements here - ) ) ) diff --git a/R/mod_DBSelector.R b/R/mod_DBSelector.R index 0f9352c..501500e 100644 --- a/R/mod_DBSelector.R +++ b/R/mod_DBSelector.R @@ -92,19 +92,16 @@ filtra_datos <- function(datos_filtrados, #' DBSelector Server Function #' -#' Using the filters selected in the UI the function returns a reactive function that returns -#' a dataframe filtered using the corresponding filters. -#' +#' A partir de los filtros seleccionados por el usuario regresa un reactive con +#' los datos filtrados. #' #' #' @keywords internal #' @param input shiny internal #' @param output shiny internal #' @param session shiny internal -#' @param interval_ba_rea Interval reactive that returne time -#' interval to select data -#' @return reactive function that returns a filtered dataframe -#' using the inputs from the UI +#' @param interval_ba_rea reactive con los valores seleccionados en la barra de tiempo +#' @return reactive con el dataframe de los valores filtrados mod_DBSelector_server <- function(input, output, session, interval_ba_rea, datos_filtrados) { ns <- session$ns @@ -133,7 +130,6 @@ mod_DBSelector_server <- function(input, output, session, }) %>% bindCache(input$filtro_incidente, input$filtro_bd, interval_ba_rea(), input$filtro_lugar) - #datafram_re <- datafram_re %>% shiny::debounce(100) seleccion_lugar <- reactive({ input$filtro_lugar }) diff --git a/R/mod_bar.R b/R/mod_bar.R index 2673c6b..bd249d9 100644 --- a/R/mod_bar.R +++ b/R/mod_bar.R @@ -1,6 +1,6 @@ #' bar UI Function #' -#' Generate a bar to get a time interval +#' Genera la UI para el slider de tiempo. #' #' #' @param id Internal parameters for {shiny}. @@ -25,9 +25,9 @@ mod_bar_ui <- function(id) { } #' Bar Server Function -#' ¿ -#' The function returns a reactive function that returns a vectors with the -#' date of the interval +#' +#' Regresa un reactive con los valores seleccionados en un vector +#' strings Y-m-d #' #' @param input shiny internal #' @@ -35,8 +35,7 @@ mod_bar_ui <- function(id) { #' #' @param session shiny internal #' -#' @return Reactive function that returns a vector with a time interval -#' (min, max) dates +#' @return reactive con los valores seleccionados c(fecha_min, fecha_max) strings Y-m-d mod_bar_server <- function(input, output, session) { ns <- session$ns interval_val <- reactive({ diff --git a/R/mod_graficas.R b/R/mod_graficas.R index ac647bf..c4365f3 100644 --- a/R/mod_graficas.R +++ b/R/mod_graficas.R @@ -1,10 +1,10 @@ #' graficas UI Function #' -#' UI function that produces the graphic interface to select the type of plots -#' and the interval to generate them. +#' Función de UI que produce las gráficas y los controles para +#' seleccionar el tipo de gráfica de acuerdo a los datos seleccionados +#' en DBSelector. #' -#' -#' @param id shiny parameter for the different sessions +#' @param id parámetro de shiny para diferentes sesiones #' #' #' @importFrom shiny NS tagList @@ -75,17 +75,18 @@ mod_graficas_ui <- function(id) { -#' Graficas Mes Dia Function +#' Función de Gráficas Mes/Dia #' -#' Generates the graph of the "Incidentes viales" by month or daily +#' Genera las gráficas de "Incidentes viales" por mes o diarias #' #' -#'@param input shiny parameter where the inputs from the UI are store -#'and the month or day graph is selected +#'@param input Los valores seleccionados por el usuario en la función UI +#' input$tiempo_grafica Temporalidad de la gráfica +#' input$Datos_grafica Qué base de datos fgraficar #' -#'@param dataframe_rec_in The reactive function that returns a dataframe +#'@param dataframe_rec_in El reactive con los datos seleccionados en DBSelector #' -#'@returns The render plot selected in the UI +#'@returns La gráfica renderizada mes_dia_graf <- function(dataframe_rec_in, input) { renderPlot({ if (input$tiempo_grafica == "Mensual") { @@ -138,8 +139,6 @@ mes_dia_graf <- function(dataframe_rec_in, input) { AXA = "#5E0061") p <- p + ggplot2::geom_line() + - - #ggplot2::scale_x_date(breaks = "1 month") + ggplot2::scale_x_date( minor_breaks = function(x) seq.Date(from = min(x), to = max(x), @@ -162,12 +161,12 @@ mes_dia_graf <- function(dataframe_rec_in, input) { ) } else if (input$tiempo_grafica == "Diaria") { - ############## Por DIA#################### + ### Por DIA ### datos <- dataframe_rec_in() if (input$Datos_grafica != "Todas") { datos <- datos[datos$fuente == input$Datos_grafica, ] } - ########### Agrupar################### + ### Agrupar ### count_months_year <- dplyr::count(datos, lubridate::day(datos$timestamp), lubridate::month(datos$timestamp), @@ -184,7 +183,7 @@ mes_dia_graf <- function(dataframe_rec_in, input) { format = "%d/%m/%Y" ) count_months_year$fuente <- as.factor(count_months_year$fuente) - ##########Grafica + ### Grafica ### if (length(unique(datos$fuente)) != 1) { p <- ggplot2::ggplot( data = count_months_year, @@ -211,7 +210,6 @@ mes_dia_graf <- function(dataframe_rec_in, input) { ggplot2::geom_smooth( method = "loess" ) + - #ggplot2::scale_x_date(breaks = "2 week") + ggplot2::scale_x_date(minor_breaks = function(x) seq.Date(from = min(x), to = max(x), @@ -237,6 +235,7 @@ mes_dia_graf <- function(dataframe_rec_in, input) { return(p) } ) %>% + # Esto lo liga al cache (shiny >= 1.6) bindCache(input$Datos_grafica, input$tiempo_grafica, dataframe_rec_in()) }