-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmod_outputs.R
More file actions
34 lines (30 loc) · 934 Bytes
/
Copy pathmod_outputs.R
File metadata and controls
34 lines (30 loc) · 934 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
mod_outputs_ui <- function(id) {
ns <- NS(id)
tagList(
plotOutput(ns("graf_vida")),
plotOutput(ns("graf_pib"))
)
}
mod_outputs_server <- function(id, pais_input) {
moduleServer(id, function(input, output, session) {
datos_filtrados <- reactive({
req(pais_input())
paises %>% filter(pais == pais_input())
})
output$graf_vida <- renderPlot({
df <- datos_filtrados()
ggplot(df, aes(x = anio, y = esperanza_de_vida)) +
geom_line() +
geom_point() +
labs(title = paste("Esperanza de vida en", pais_input()),
x = "Año", y = "Esperanza de vida")
})
output$graf_pib <- renderPlot({
df <- datos_filtrados()
ggplot(df, aes(x = anio, y = pib_per_capita)) +
geom_col(fill = "#3182bd") +
labs(title = paste("PIB per cápita en", pais_input()),
x = "Año", y = "PIB per cápita")
})
})
}