1

New to shiny, I'm currently building a basic app that acts people counter that updates a remote google sheet, I've narrowed down the problem to the function dataTableOutput() and its returning: Error: argument is not interpretable as logical

I've scoured Shiny's function description site, as well as other (somewhat) related problems on here, and tutorials. The error code goes away when I remove it, but the app crashes, I've also made sure to update all packages and the version of R that I'm using. I'm also running it on anaconda's IDE.

fields <- c("Pool", "Table Tennis", "Arcade Games",
            "Console Games", "Board Games", "Air Hockey",
            "Cornhole")

Maindata <- c("date","semester", "games", "num")

semesters <- c("Spring", "Summer", "Fall")

ui <- fluidPage(

  titlePanel("Corner Pocket Customer Counter"),
    sidebarLayout(

      sidebarPanel(

        dataTableOutput("Game_Table"),

        checkboxGroupInput(
          inputId = "games",
          label = "Games",
          choices = fields, 
          inline = FALSE),

        numericInput(
          inputId = "num",
          label = "Number of Customers",
          min = 0,
          max = 1000,
          value = 0,
          step = 1),

        dateInput(
          inputId = "date",
          label = "Today's Date",
          value = Sys.Date()),

        checkboxGroupInput(
          inputId = "semester",
          label = "Semester",
          choices = semesters, 
          inline = FALSE),

        actionButton(
          inputId = "submit",
          label = "Submit")
        ),
      mainPanel()
      )
  )

server <- function(input, output, session) {

  formData <- reactive({
    data <- sapply(Maindata, function(x) input[[x]])
    data
  })


  observeEvent(input$submit, {
    saveData(formData())
  })

  output$Game_Table <- renderDataTable({
    input$submit
    loadData()
  })

}
  table <- "Game_Table"

  saveData <- function(data) {
    # Grab the google sheet
    table %>% gs_title("Sheet Key") %>% gs_add_row(input = data)
  }

  loadData <- function() {
    table %>% gs_title("Sheet Key ") %>% gs_read_csv
  }



shinyApp(ui = ui, server = server)

Basically, The output should just be an updating of the google sheet with what ever the person inputs as far as counts, date, what they did etc. I'm not sure what logical dataTableOutput() is throwing.

Sebastian Goslin
  • 477
  • 1
  • 3
  • 22
  • See the last answer here https://stackoverflow.com/questions/32149487/controlling-table-width-in-shiny-datatableoutput for the important note about using DT as a prefix. Also note the error could be thrown from your `renderDataTable` in the server as well. – Chabo Jan 08 '19 at 20:58
  • @Chabo I tried changing that already, the width shouldn't be of concern in this context, you may be right on `renderDataTable()` I expected that it might have to do with it waiting for the user to submit an answer thats throwing the error, but I already tried getting rid of the submit input and the error still occurs. – Sebastian Goslin Jan 08 '19 at 21:11
  • Try assigning `loadData()` to a non-reactive varaible before rendering. Under the render function try `Load_Data<- loadData()` using `Load_Data` as the DT to render. If that does not work ensure the class of `loadData` is suitable to be rendered in this fashion – Chabo Jan 08 '19 at 21:43
  • 1
    @Chabo Sorry for the late reply, I've fixed the logical issue, `dataTableOutput()` was correct, the issue arose with the inability to correctly access the Googlesheet title, I am able to read it now, just by listing the name of the specific sheet. Once I provided access to my private sheet it was able to work. Thank you for replying though I know it was a very vague question! – Sebastian Goslin Jan 09 '19 at 14:59

1 Answers1

0

I've fixed the logical issue, dataTableOutput() was correct, the issue arose with the inability to correctly access the Googlesheet title, I am able to read it now, just by listing the proper name of the specific sheet. Once I provided access for Googlesheets to Shiny to my private sheet it was able to work. Make sure gs_title() has the correct sheet name (title) in it!

Sebastian Goslin
  • 477
  • 1
  • 3
  • 22