-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathModularTrendDisplay.R
More file actions
44 lines (30 loc) · 867 Bytes
/
ModularTrendDisplay.R
File metadata and controls
44 lines (30 loc) · 867 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
35
36
37
38
39
40
41
42
43
44
library(ggplot2)
library(plotly)
# MODULE UI
TrendDisplayUI <- function(id) {
ns <- NS(id)
fillCol(
div(
selectInput(ns("xvar"), "Select X Variable", choices = NULL),
selectInput(ns("yvar"), "Select Y Variable", choices = NULL),
plotlyOutput(ns("plot1"))
)
)
}
# MODULE Server
TrendDisplayServer <- function(input, output, session, data) {
ns <- session$ns
observe({
updateSelectInput(session, "xvar", "Select X Variable", choices = colnames(data()))
updateSelectInput(session, "yvar", "Select Y Variable", choices = colnames(data()))
})
x_var <- reactive({input$xvar})
y_var <- reactive({input$yvar})
# plotly
output$plot1 <- renderPlotly({
p <- ggplot(data(), aes_string(x = x_var(), y = y_var())) +
geom_point() +
geom_line()
ggplotly(p)
})
}