Is this the sort of think you are looking for? One can use a reactiveValues object to store the results but it does not provide any benefit in this simple example, so I edited out that line as a comment.
library(shiny)
set.seed(1)
DF <- data.frame(A = rnorm(10), B = rnorm(10, 2, 1), C = rnorm(10, 6, 1))
ui <- pageWithSidebar(
headerPanel("My First Shiny App"),
sidebarPanel(
selectInput("element", "List Element", choices = names(DF))
),
mainPanel(
tableOutput("myTable")
)
)
server <- function(input, output, session){
#values <- reactiveValues()
values <- lapply(DF, mean)
output$myTable <- renderTable({
values[[input$element]]
})
}
# Run the application
shinyApp(ui = ui, server = server)