I am trying to use the values$df dataframe variable from server.R in ui.R to display all the field names of the dataframe as checkbox in the side panel. But I get an error saying Error: object 'values' not found.
Here is what I have in the server.R file:
values<- reactiveValues()
values$df<- data.frame() # creates an empty dataframe
# actionButton
mdf<- eventReactive(input$click_counter, {
name<- input$name
gender<- input$gender
college<- input$college
team<- input$team
score<- input$score
new_row<- data.frame(name,college,gender,team,score)
return(new_row)
})
observeEvent(input$click_counter, {
name<- input$name
gender<- input$gender
college<- input$college
team<- input$team
score<- as.numeric(input$score) # convert to numeric here to make sorting possible
rank<- 0
new_row<- data.frame(rank,name,college,gender,team,score)
values$df<- rbind(values$df, new_row)
values$df<- values$df[order(-values$df$score),]
values$df$rank<- 1:nrow(values$df)
})
output$nText<- renderDataTable({
mdf()
})
output$nText2<- renderDataTable({
values$df
}, options = list(orderClasses = TRUE,lengthMenu = c(5, 10, 30), pageLength = 5))
And this is what I have in the ui.R file:
sidebarLayout(
sidebarPanel(
checkboxGroupInput('nText2',
'Columns in players to show:',
names(values$df),
selected = names(values$df))
),
valuesanywhere in your code, so it can't runrbind(values$df, new_row)- Gaurav BansalcheckboxGroupInput()to the server side withrenderUI()and then just call thehtmlOutput("nText2")in the user interface. This will allow the UI to be dependent on the outcome of the server side operation. Calling the reactive value from the server in the UI asvalues$dfis not generally how the UI interacts with the server. - Ryan Mortonvaluesdefined outside a reactive function. Tryisolate(values$df)on UI side - user5249203