Oubox Boxes above MainPanel Table in RShiny

Suppose I have a numeric column named 'Sales' in a Dataframe. There are 1000 rows (Suppose). And values range from 50$ to say 3500$.

My Rshiny app has 2 sections. SideBar layout and MainPanel. Main Panel has this Dataframe as a Table. I am calculating the mean and variance of this Sales column and want to show it in separate boxes above the main panel table. Is there any reference code for such an UI setup ? Please help

You would just need to add on top of the table output within mainPanel, something like this (I used the skimr package for displaying the table stats.

#> Attaching package: 'DT'
#> The following objects are masked from 'package:shiny':
#>     dataTableOutput, renderDataTable

sales_vec = round(runif(1000,min = 50, max = 3500))
my_tibble = tibble(Var = 1:1000, Sales = sales_vec)

ui <- fluidPage(
  sidebarLayout(sidebarPanel = sidebarPanel(
    selectInput("select_nothing", "This does nothing", choices = LETTERS[1:10])
  mainPanel = mainPanel(
    h4('Table Stats'),
    h4('Table View'),

server <- function(input, output, session) {
  output$my_table = renderDT({
  output$my_summary = renderDT({
    datatable(skim(my_tibble), options = list(dom = "t"))

shinyApp(ui, server)

Shiny applications not supported in static R Markdown documents

Created on 2020-08-13 by the reprex package (v0.3.0)

This topic was automatically closed 54 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.