0

I have the following conceptual question: How to render data inside a fluidPage. Here is the code that resumes the question:

---
title: "Dashboard"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
runtime: shiny
---
library(flexdashboard)
library(DBI)
library(RPostgreSQL)
library(tidyverse)
library(DT)
dataset <- eventReactive(input$button_execute, {
# SQL query 
dataset <- dbFetch(rs)
})

So far the query runs fine, and I want to put some results of the query inside a fluidPage:

fluidPage(
  fluidRow(
    column(2,""),
    column(8,variable1, style="text-align: center;")),
    column(2,variable2, style="text-align: center;"))
  )
)

I want variable 1 and 2 to be:

variable1 <- dataset %>% summary(total = sum(sales))
variable2 <- dataset %>% summary(mean = sum(sales))

Could you please help me with some advice on this? Thank you.

Manu
  • 1,070
  • 10
  • 27
  • Are you new to shiny? Because the usual pattern is to have some type of "output" object in the UI and then a "render" call in the server code to draw the data. You seem to have neither here. How exactly do you want to render this data in your webpage? It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. – MrFlick Feb 11 '20 at 16:38
  • Hello @MrFlick, I was working on a rmarkdown dashboard and so far it works with renderPlot and renderDataTable. But the conceptual question is if fluidPage can contain reactive values. You mean if I tried output$variable1? – Manu Feb 11 '20 at 16:44
  • 2
    A fluid page cannot directly "hold" a reactive value, but it can contain a `DTOutput` placeholder that you can call `renderDT()` with a data set to populate (at least that's why I assume you've included `library(DT)`). Some examples here: https://rstudio.github.io/DT/shiny.html – MrFlick Feb 11 '20 at 16:47
  • Hello @MrFlick, great!, I was trying code after code to show the values inside each cell of fluidPage (without success), but the link you provided gave me some ideas. Thank you. – Manu Feb 11 '20 at 16:56

0 Answers0