2

I am using rpivoTable package in my shiny dashboard. The problem is that my tables has close to 25 variables (columns) whereas I am only able to view 10 columns. Rest are out of view and there's no slider also to view them.

Best,

nicolaskruchten
  • 26,384
  • 8
  • 83
  • 101
Akshit
  • 349
  • 1
  • 3
  • 10

1 Answers1

6

I find one way -- add css to that pivot

tags$head(tags$style( type = 'text/css',  '#pivot{ overflow-x: scroll; }')),
          rpivotTableOutput('pivot', width = "100%", height = "500px")

for example

UI

library(shiny)
library(rpivotTable)
library(shinydashboard)
shinyUI(dashboardPage(
  dashboardHeader(title = "example"),
  dashboardSidebar(disable = T),
  dashboardBody(

      tags$head(tags$style( type = 'text/css',  '#pivot{ overflow-x: scroll; }')),
      rpivotTableOutput('pivot', width = "100%", height = "500px")
  )

))

server

df=data.frame(lapply(1:25,function(i)i=rnorm(20)))
colnames(df)=as.character(letters[1:25])

shinyServer(function(input, output,session) {

  output$pivot <- renderRpivotTable({
    rpivotTable(data = df)
  })


})
Batanichek
  • 7,761
  • 31
  • 49
  • Thanks for the prompt reply. But my output is not just a table its complete pivot structure. This is my output .... output$pivot <- renderRpivotTable({ rpivotTable(mydata) }) – Akshit Nov 27 '15 at 07:26
  • how you use it in ui ( or server part of UI)? add css where you code how to show your `output$pivot` – Batanichek Nov 27 '15 at 07:30
  • Add example to my answer – Batanichek Nov 27 '15 at 07:42
  • I am adding this pivot in a dashboard tab.. tabItem(tabName = "trains", fluidRow(br(),rpivotTable::rpivotTableOutput('pivot')) ) – Akshit Nov 27 '15 at 09:20
  • try `tabItem(tabName = "trains", fluidRow(br() , tags$head(tags$style( type = 'text/css', '#pivot{ overflow-x: scroll; }')) ,rpivotTable::rpivotTableOutput('pivot')) )` or see my edit – Batanichek Nov 27 '15 at 09:30
  • @Batanichek Would it be possible to do the same without using `shiny` ? (how to pass custom `css` directly to a chunk in `flexdashboard`) – Steven Beaupré Aug 23 '16 at 16:57
  • 1
    @StevenBeaupré If i understand right you need somethink like `--- title: "Test" output: flexdashboard::flex_dashboard: css: styles.css --- ```{r} library(rpivotTable) rpivotTable(iris) ``` ` in markdown and `.rpivotTable{ overflow-x: scroll; }` in styles.css – Batanichek Aug 23 '16 at 18:00