Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to center table in box in Shiny Dashboard

I'm having difficulty centering a table I made in Shiny Dashboard within a box. I used a .csv file, but here is some fake data:

Stage = c("Survey", "Work Sample", "Interview", "Stats Test")
Score = c("+33.7%", "+14.8%", "+20.8%", "+28.17%")
no1_cand = data.frame(Stage, Score)
Score =c("+37.1%", "+14.2%", "+19.3%", "+26.3%")
no2_cand = data.frame(Stage, Score)
Score = c("+33.1%", "+22.2%", "+17.3%", "+25.8%")
no3_cand = data.frame(Stage, Score)
Score = c("+29.1%", "+17.2%", "+15.3%", "+23.3%")
no4_cand = data.frame(Stage, Score)
Score = c("+22.1%", "+12.5%", "+11.4%", "+19.5%")
no5_cand = data.frame(Stage, Score)

and the current code I have for the table and box:

#UI
    box(title = "Top 5 Candidates",
                      status = "primary",
                      solidHeader = F,
                      collapsible = T,
                      width = 12,
                      fluidRow(
                        tableOutput('top5')))
#Server
  output$top5 = renderTable({
    top5_data
  })

Currently it looks like this:

enter image description here

like image 877
skk Avatar asked Aug 22 '18 15:08

skk


People also ask

How do you center a shiny image?

You can use style="display: block; margin-left: auto; margin-right: auto;" to center an image.

What is Shinydashboard?

Background: Shiny and HTML The shinydashboard package provides a set of functions designed to create HTML that will generate a dashboard. If you copy the UI code for a dashboard page (above) and paste into the R console, it will print out HTML for the dashboard.

How do you add text to the shiny dashboard?

You can use tahs$h1() to h6() to add headings, or add text using textOutput(). You can add text using text within quotes(" ").


1 Answers

Try:

box(title = "Top 5 Candidates"
, status = "primary", solidHeader = F
, collapsible = T, width = 12
, column(12, align="center", tableOutput('top5'))) 
like image 117
Jim Chen Avatar answered Sep 20 '22 23:09

Jim Chen