I'm trying to make my first shiny app and failing miserably. I want to be able to toggle through 3 different dataframes (and present them as tables). The idea is that I render each table (A, B, C) in the main panel by selecting them in the sidebar panel.
I am part of the way there, but struggling at the "output" stage...
library(shiny)
library(dplyr)
A <- data.frame(ID = c("A", "B", "C","D"),
colour = c("red", "white", "blue", "orange"),
age =c("8", "3", "4", "5"))
B <- data.frame(ID = c("Bob", "Bill", "Jack","Dave"),
shape = c("star", "square", "circle", "triangle"),
age =c("15", "12", "13", "14"))
C <- data.frame(ID = c("Jane", "Jenny", "Bex","Sarah"),
animal = c("cat", "dog", "fish", "tiger"),
food =c("chips", "burger", "sushi", "chocolate"))
ui <- fluidPage(
titlePanel("Failing at my first shiny app"),
sidebarLayout(
sidebarPanel(
selectInput("tableInput", "Table",
choices = c("A", "B", "C"))
),
mainPanel(
tableOutput("results")
)
)
)
server <- function(input, output) {
output$results <- renderTable({
#want to toggle through objects here
#how do I do it?!
})
}
shinyApp(ui = ui, server = server)
If anyone can point me in the right direction, I'd be ever grateful! Thanks!
