-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.R
106 lines (82 loc) · 2.62 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
library(dplyr)
library(shiny)
library(ggplot2)
library(viridis)
library(markdown)
source("linked_scatter.R")
source("radial_plots.R")
cammet <- readRDS("data/CamMetCleanish.RData")
ui <- shinyUI(fluidPage(
navbarPage("Cambridge Weather",
tabPanel("Basic",
sidebarLayout(
sidebarPanel(
helpText("Explore ", tags$a(href = "https://www.cl.cam.ac.uk/research/dtg/weather/",
"ComLab"),
"weather measurements:"),
selectInput("year",
strong("Choose year"),
choices = yearChoices,
selected = "2019"),
selectInput("selectX",
strong("Choose x variable"),
choices = plotChoices,
selected = "temperature"),
selectInput("selectY",
strong("Choose y variable"),
choices = plotChoices,
selected = "dew.point")
),
mainPanel(
plotOutput("plot")
)
)
),
tabPanel("Brushed",
textOutput("summary"),
linkedScatterUI("scatters")
),
tabPanel("Radial",
radialUI("radials")
),
# Coming soon ...
#tabPanel("Models",
# includeMarkdown("models.md")
#),
tabPanel("About",
includeMarkdown("README.md")
)
)))
server <- shinyServer(function(input, output, session) {
df <- callModule(linkedScatter,
"scatters",
reactive(cammet %>%
filter(year == input$advYear)),
left = reactive(c(input$selectLeftX, input$selectLeftY)),
right = reactive(c(input$selectRightX, input$selectRightY))
)
output$summary <- renderText({
sprintf("%d observation(s) selected", sum(df()$selected_))
})
radDF <- reactive(cammet %>%
filter(year == input$radialYear) %>%
group_by(as_date = as.Date(ds)) %>%
summarise(minx = min(!! rlang::sym(input$radialX)),
maxx = max(!! rlang::sym(input$radialX)),
meanx = mean(!! rlang::sym(input$radialX))))
callModule(radialPlot,
"radials",
radDF,
reactive(input$radialYear),
reactive(input$radialX))
data <- reactive({
cammet %>%
filter(year == input$year)
})
output$plot <- renderPlot({
ggplot(data(), aes_string(x = input$selectX, y = input$selectY)) +
geom_point() +
scale_color_manual(guide = FALSE)
})
})
shinyApp(ui = ui, server = server)