Skip to content

Commit 4bf5e61

Browse files
committed
Documentación.
1 parent 9d7cfc0 commit 4bf5e61

File tree

5 files changed

+31
-37
lines changed

5 files changed

+31
-37
lines changed

R/app_server.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#' The application server-side
2+
#' Define la estructura general de la aplicación
3+
#' sidebar, paneles, etc
24
#'
35
#' @param input,output,session Internal parameters for {shiny}.
46
#' DO NOT REMOVE.

R/app_ui.R

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#' The application User-Interface
2+
#' Los elementos de la UI que corresponden a la estructura
3+
#' del server side
24
#'
35
#' @param request Internal parameter for `{shiny}`.
46
#' DO NOT REMOVE.
@@ -7,18 +9,16 @@
79

810
app_ui <- function(request) {
911
shinydashboard::dashboardPage(
10-
# title = 'Visualizador de Datos de Incidentes Viales - SEMOVI',
11-
# skin = 'green',
1212
shinydashboard::dashboardHeader(
1313
title = "Visualizador de Datos de Incidentes Viales - SEMOVI"),
1414
shinydashboard::dashboardSidebar(shinydashboard::sidebarMenuOutput("menu")),
1515
shinydashboard::dashboardBody(shinydashboard::tabItems(
16-
##############Introduccion##########
16+
### Introduccion ###
1717
shinydashboard::tabItem(tabName = "intro",
1818
mod_introPageUI_ui("introPageUI_ui_1")
1919
),
2020
shinydashboard::tabItem(tabName = "bd", mod_infoBdUI_ui("infoBdUI_ui_1")),
21-
########### Visualizador#################
21+
### Visualizador ###
2222
shinydashboard::tabItem(
2323
tabName = "visualizador",
2424
fluidPage(
@@ -32,7 +32,7 @@ app_ui <- function(request) {
3232
)
3333
)
3434
),
35-
######## Actualizacion########
35+
### Actualizacion ###
3636
shinydashboard::tabItem(tabName = "actualiza",
3737
mod_csvFileUI_ui("csvFileUI_ui", label = "Selecciona un CSV"),
3838
DT::dataTableOutput("tabla")
@@ -41,8 +41,6 @@ app_ui <- function(request) {
4141
tagList(
4242
# Leave this function for adding external resources
4343
golem_add_external_resources(),
44-
# List the first level UI elements here
45-
4644
)
4745
)
4846
)

R/mod_DBSelector.R

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,19 +92,16 @@ filtra_datos <- function(datos_filtrados,
9292

9393
#' DBSelector Server Function
9494
#'
95-
#' Using the filters selected in the UI the function returns a reactive function that returns
96-
#' a dataframe filtered using the corresponding filters.
97-
#'
95+
#' A partir de los filtros seleccionados por el usuario regresa un reactive con
96+
#' los datos filtrados.
9897
#'
9998
#'
10099
#' @keywords internal
101100
#' @param input shiny internal
102101
#' @param output shiny internal
103102
#' @param session shiny internal
104-
#' @param interval_ba_rea Interval reactive that returne time
105-
#' interval to select data
106-
#' @return reactive function that returns a filtered dataframe
107-
#' using the inputs from the UI
103+
#' @param interval_ba_rea reactive con los valores seleccionados en la barra de tiempo
104+
#' @return reactive con el dataframe de los valores filtrados
108105
mod_DBSelector_server <- function(input, output, session,
109106
interval_ba_rea, datos_filtrados) {
110107
ns <- session$ns
@@ -133,7 +130,6 @@ mod_DBSelector_server <- function(input, output, session,
133130
}) %>%
134131
bindCache(input$filtro_incidente, input$filtro_bd,
135132
interval_ba_rea(), input$filtro_lugar)
136-
#datafram_re <- datafram_re %>% shiny::debounce(100)
137133
seleccion_lugar <- reactive({
138134
input$filtro_lugar
139135
})

R/mod_bar.R

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#' bar UI Function
22
#'
3-
#' Generate a bar to get a time interval
3+
#' Genera la UI para el slider de tiempo.
44
#'
55
#'
66
#' @param id Internal parameters for {shiny}.
@@ -25,18 +25,17 @@ mod_bar_ui <- function(id) {
2525
}
2626

2727
#' Bar Server Function
28-
#' ¿
29-
#' The function returns a reactive function that returns a vectors with the
30-
#' date of the interval
28+
#'
29+
#' Regresa un reactive con los valores seleccionados en un vector
30+
#' strings Y-m-d
3131
#'
3232
#' @param input shiny internal
3333
#'
3434
#' @param output shiny internal
3535
#'
3636
#' @param session shiny internal
3737
#'
38-
#' @return Reactive function that returns a vector with a time interval
39-
#' (min, max) dates
38+
#' @return reactive con los valores seleccionados c(fecha_min, fecha_max) strings Y-m-d
4039
mod_bar_server <- function(input, output, session) {
4140
ns <- session$ns
4241
interval_val <- reactive({

R/mod_graficas.R

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#' graficas UI Function
22
#'
3-
#' UI function that produces the graphic interface to select the type of plots
4-
#' and the interval to generate them.
3+
#' Función de UI que produce las gráficas y los controles para
4+
#' seleccionar el tipo de gráfica de acuerdo a los datos seleccionados
5+
#' en DBSelector.
56
#'
6-
#'
7-
#' @param id shiny parameter for the different sessions
7+
#' @param id parámetro de shiny para diferentes sesiones
88
#'
99
#'
1010
#' @importFrom shiny NS tagList
@@ -75,17 +75,18 @@ mod_graficas_ui <- function(id) {
7575

7676

7777

78-
#' Graficas Mes Dia Function
78+
#' Función de Gráficas Mes/Dia
7979
#'
80-
#' Generates the graph of the "Incidentes viales" by month or daily
80+
#' Genera las gráficas de "Incidentes viales" por mes o diarias
8181
#'
8282
#'
83-
#'@param input shiny parameter where the inputs from the UI are store
84-
#'and the month or day graph is selected
83+
#'@param input Los valores seleccionados por el usuario en la función UI
84+
#' input$tiempo_grafica Temporalidad de la gráfica
85+
#' input$Datos_grafica Qué base de datos fgraficar
8586
#'
86-
#'@param dataframe_rec_in The reactive function that returns a dataframe
87+
#'@param dataframe_rec_in El reactive con los datos seleccionados en DBSelector
8788
#'
88-
#'@returns The render plot selected in the UI
89+
#'@returns La gráfica renderizada
8990
mes_dia_graf <- function(dataframe_rec_in, input) {
9091
renderPlot({
9192
if (input$tiempo_grafica == "Mensual") {
@@ -138,8 +139,6 @@ mes_dia_graf <- function(dataframe_rec_in, input) {
138139
AXA = "#5E0061")
139140
p <- p +
140141
ggplot2::geom_line() +
141-
142-
#ggplot2::scale_x_date(breaks = "1 month") +
143142
ggplot2::scale_x_date(
144143
minor_breaks = function(x) seq.Date(from = min(x),
145144
to = max(x),
@@ -162,12 +161,12 @@ mes_dia_graf <- function(dataframe_rec_in, input) {
162161
)
163162
}
164163
else if (input$tiempo_grafica == "Diaria") {
165-
############## Por DIA####################
164+
### Por DIA ###
166165
datos <- dataframe_rec_in()
167166
if (input$Datos_grafica != "Todas") {
168167
datos <- datos[datos$fuente == input$Datos_grafica, ]
169168
}
170-
########### Agrupar###################
169+
### Agrupar ###
171170
count_months_year <- dplyr::count(datos,
172171
lubridate::day(datos$timestamp),
173172
lubridate::month(datos$timestamp),
@@ -184,7 +183,7 @@ mes_dia_graf <- function(dataframe_rec_in, input) {
184183
format = "%d/%m/%Y"
185184
)
186185
count_months_year$fuente <- as.factor(count_months_year$fuente)
187-
##########Grafica
186+
### Grafica ###
188187
if (length(unique(datos$fuente)) != 1) {
189188
p <- ggplot2::ggplot(
190189
data = count_months_year,
@@ -211,7 +210,6 @@ mes_dia_graf <- function(dataframe_rec_in, input) {
211210
ggplot2::geom_smooth(
212211
method = "loess"
213212
) +
214-
#ggplot2::scale_x_date(breaks = "2 week") +
215213
ggplot2::scale_x_date(minor_breaks =
216214
function(x) seq.Date(from = min(x),
217215
to = max(x),
@@ -237,6 +235,7 @@ mes_dia_graf <- function(dataframe_rec_in, input) {
237235
return(p)
238236
}
239237
) %>%
238+
# Esto lo liga al cache (shiny >= 1.6)
240239
bindCache(input$Datos_grafica, input$tiempo_grafica, dataframe_rec_in())
241240
}
242241

0 commit comments

Comments
 (0)