-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.R
56 lines (41 loc) · 1.25 KB
/
app.R
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Note, this app can't be developed in bluevelvet.
rm(list=ls())
library(shiny)
library(tidyverse)
d <- readRDS("/figures/risk-factor/figure-data/all_forest_plot_RR.RDS")
df <- d %>% filter()
intervention_options <- dplyr::count(df, intervention_variable, sort = TRUE)[1]
outcome_options <- dplyr::count(df, outcome_variable, sort = TRUE)[1]
age_options <- dplyr::count(df, agecat, sort = TRUE)[1]
ui <- fluidPage(
titlePanel("Relative risk forest plots"),
sidebarLayout(
sidebarPanel(
selectInput(
"exposure", "Pick an exposure: ", intervention_options,
),
selectInput(
"outcome", "Pick an outcome: ", outcome_options,
),
selectInput(
"age", "Pick an age: ", age_options,
),
h5("Note: No plot will be displayed with invalid inputs.")
),
mainPanel(
plotOutput("selected_plot")
)
)
)
server <- function(input, output, session) {
datasetInput <- reactive({
df %>% filter(intervention_variable == input$exposure &
outcome_variable == input$outcome &
agecat == input$age)
})
output$selected_plot <- renderPlot({
dataset <- datasetInput()
dataset$plot
})
}
shinyApp(ui, server)