-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdisplay.R
More file actions
56 lines (48 loc) · 1.39 KB
/
display.R
File metadata and controls
56 lines (48 loc) · 1.39 KB
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
# ------------------------------------------------------------------------------
# Display tabs
# A reactive base graphic
base_plot = reactive({
# Wait until user has chosen variables before trying to plot
req(input$explan)
req(input$resp)
# Base plot with no options
base_plot <- ggplot(data_in(),
aes_string(x = input$explan, y = input$resp))+
geom_point()
base_plot
})
# Another reactive graphic
the_plot <- reactive({
# Add title if specified
the_plot <- base_plot() +
ggtitle(input$plot_title)
# Add line of best fit if requested
if(input$best_fit){
the_plot <- base_plot() +
geom_smooth(method = "lm", se = FALSE)
}
the_plot
})
# Output of reactive graphic
output$dist_plot_main <- renderPlot({
if(is.null(data_in())) return()
print(the_plot())
})
# Output of reactive graphic
output$dist_plot_meta <- renderPlot({
if(is.null(data_in())) return()
meta_plot <- pharmaTag(the_plot(), protocol = "ABC", population = "ITT")
})
# Return the data
output$data_view <- renderDT({
if(is.null(data_in())) return()
datatable(data_in(), options = list(scrollX = TRUE))
})
output$display_tabs <- renderUI({
req(input$file_in)
tabsetPanel(type="tabs",
tabPanel("Main", plotOutput("dist_plot_main")),
tabPanel("Meta", plotOutput("dist_plot_meta")),
tabPanel("Data", DTOutput("data_view"))
)
})