I think we're almost there. There are few steps left.
server
I made a few changes to my previous reply.
Reading the file input does not need to be triggered by input$file. This should be defined outside of all observeEvents.
# first line in server
values <- reactive({ read.csv(input$file$datapath) })
Next,
I'm not sure if these lines are specific to the file you are working from, but values$df_data was replaced by values().
ui
After reading over the ui block, I noticed that the actionButton Go is missing. Perhaps this got accidentally cut somewhere in the previous comments. I added the button after the selectInput.
# button
actionButton(inputId = "Go",label = "Go")
The choices for selectInput should also be set to "" (blanks) as the content will be updated from the server (updateSelectInput). This would like this:
# input
selectInput(
inputId = "Question",
label = h1("Response to be analysed"),
choices="",
selected=""
)
Full example
I saved a sample dataset to my desktop
write.csv(mtcars, "~/Desktop/mtcars.csv",row.names = FALSE)
library(shiny)
library(shinydashboard)
# ui
ui <- shinyUI(
dashboardPage(
# header
dashboardHeader(title="Feedback Analysis"),
# sidebar
dashboardSidebar(
fileInput("file","Upload CSV files",multiple=TRUE,accept=("text/comma")),
# sidebar menu
sidebarMenu(id="tabs",
# option
menuItem(text = "Data", tabName="Data", icon=icon("table"), startExpanded = TRUE),
# option
menuItem("Descriptive Analysis", tabName="Feedback Analysis",
# input
selectInput(inputId = "Question",
label = h1("Response to be analysed"),
choices="",
selected=""),
# button
actionButton(inputId = "Go",label = "Go")
)
)
),
# body
dashboardBody(
tabItems(
# tab 1: data
tabItem(tabName="Data", h2("Data Set"),tableOutput("data.frame")),
# tab 2: rcount
tabItem(tabName="Feedback Analysis",h3("Feedback Analysis"),
tableOutput("rcount")
)
)
)
)
)
server <- shinyServer(function(input,output,session){
# read file
values <- reactive({ read.csv(input$file$datapath) })
# observeEvent for input$file
observeEvent(input$file, {
# update selectInput#Question
updateSelectInput(
session,
inputId = "Question",
choices=names(values()),
selected=names(values())[1]
)
})
# observeEvent for input$Go
observeEvent(input$Go, {
# temp <- values([-input$Delete, ] # commented for now
# values <- temp # commented for now
# render tables
output$data.frame <- renderTable(values())
# commented for now
# output$rcount <- renderTable(table(input$Question),"Response Count")
})
})
shinyApp(ui, server)
I didn't assign any behaviors to transform the data before rendering as I'm not sure of the end goal. The above example should get the table to render after a file is uploaded and the Go button is clicked.