Reformulating my question, I´m trying to synthetize a data frame reactively, with a selectinput = c("col_1","col_2","col_3","col_4","col_5")
My dataframe looks something like this
Date . Store_ID . Sales . Stock . ETC
I need to be able to sum all the data in the same stores, with the different user selected columns.
Using the mtcars dataframe as an example to work with, my objective is to have a table like this
SelectInput = disp
cyl - disp
4 - sum(every 4 cylinders disp)
6 - sum(every 6 cylinders disp)
8 - sum(every 8 cylinders disp)
SelectInput = qsec
cyl . qsec
4 . sum(every 4 cylinders qsec)
6 . sum(every 6 cylinders qsec)
8 . sum(every 8 cylinders qsec)
library(shiny)
library(tidyverse)
ui <- bootstrapPage(
selectInput(
"col",
"Column",
colnames(mtcars),
selected = "mpg"),
plotOutput("histCentile", height = 200)
)
server <- function(input, output) {
data <- reactive({
mtcars() %>%
group_by(cyl = cyl) %>%
pull(input$col) %>%
sum()
})
output$histCentile <- renderPlot({
hist(data()$[[input$col]],
main = "Graph",
xlab = "Units",
xlim = range(data()$[[input$col]]),
col = '#00DD00',
border = 'white')
})
}
# Run the application
shinyApp(ui = ui, server = server)