Display Count of rows in dataframe

Hi, I want to display the count of rows of a data frame in the HTML

The ui variable is set like this:

ui <- fluidPage(
    textOutput("games_count"),
    tableOutput("df_games_today"),
)

my server function is this:

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

  dataset_games <- reactive({
    dataset_games <-  dbGetQuery(con, query_games_today)
  })
   

output$df_games_today <- renderTable({
    dataset_games()
    })

  output$games_count <- renderText({
    dataset_games <- dbGetQuery(con, query_games_today)
    games_count <- nrow(dataset_games)
  })
}

Is there a way to get the nrow for the data frame "df_games_today" without having to run the dbGetQuery twice? Total newbie here to shiny so I apologize in advance. I'm former web developer that is now a data engineer and I'm working hard on figuring out this R syntax.

 output$games_count <- renderText({
   nrow(req(dataset_games()))
  })

That did it! Thank you sir!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.