user6191179
user6191179

Reputation:

Displaying data pulled from googlesheets in Shiny

I'm trying to access data from a Google spreadsheet and display it as a table in a Shiny app. After confirmation that the spreadsheet was accessed, the app continues to run without displaying anything. Printing the data to the console works, however.

server.R

library(shiny)
library(googlesheets)

shinyServer(function(input, output) {
  sheet <- gs_title("Google Sheet")
  data <- gs_read_csv(sheet)

  output$table <- renderTable{
    data
  }
})

ui.R

library(shiny)
shinyUI(pageWithSidebar(
  mainPanel(
    dataTableOutput('table')
  )
))

Upvotes: 0

Views: 1904

Answers (1)

Mikael Jumppanen
Mikael Jumppanen

Reputation: 2486

In server.Ruse renderDataTable({}) if you use dataTableOutput()

This code works:

library(shiny)
library(googlesheets)

server <- function(input, output) {
  sheet <- gs_title("Google Sheet")
  data <- gs_read_csv(sheet)

  output$table <- renderDataTable({
    data
  })
}

ui <- fluidPage(sidebarLayout(sidebarPanel("Test"),
                              mainPanel(dataTableOutput('table'))
                              )
                )

shinyApp(ui = ui, server = server)

Upvotes: 3

Related Questions