-
Notifications
You must be signed in to change notification settings - Fork 0
Visualize
as all the other tabs this page is composed of two boxes
Through a selectInput("chart")
you can select the type of graph that you want to display. There are different types
- Bar chart
- Carpet
- ...
For each chart selected a conditional panel permits to visualize the variables related to each chart type. For example you chose Histogram, then the corresponding code for the UI and the server function is the following.
#### UI
conditionalPanel("input.chart == 'Histogram'", # conditions if a particular chart is selected
uiOutput("inBoxHistogram") # calls the server INPUT BOX function of the related chart
)
#### SERVER
output$inBoxHistogram <- renderUI({
if (!is.null(input$file)) { # avoids to display error if no file in input
tagList( selectInput(), ...) # a list of input widgets
})
At the end of the input plot there will always be an action button to plot the corresponding graph in the outBox.
actionButton("plotButton", "Plot", style = "color: #fff; background-color: red; border-color: #red")
A download button permits to download the graph.
downloadButton('downloadplotButton', 'Download', style = "width:100%;")
The output box permits to visualize the selected chart.
when the plot action button is clicked a plotting function eventReactive()
and the UI output renderPlot()
functions are called. Those function depend on the type of chart you want to visualize but has always the same structure. For example if you chose Histogram, the server side functions are the following.
#### UI
conditionalPanel("input.chart == 'Histogram'", # conditions if a particular chart is selected
uiOutput("outBoxHistogram") # calls the server OUTPUT BOX function of the related chart
)
#### SERVER
plotHistogram <- eventReactive(input$plotButton,{ # reacts to the pressing of plotButton
aes_x <- input$variableX # some variables defined depending on the input
plot <- ggplot(data = data$df_out, # dataset to plot
mapping = aes_string(x = aes_x, ...)) + # mapping arguments imputed as string
geom()... # the plot construction # other plot customization
plot
})
output$outBoxHistogram <- renderPlot({ plotBar() }) # calls the plotting function when print button pressed