0

Can someone please help me in removing Totals coming up in RpivotTable as shown in the diagram. I'm adding the code as well. Stuck on its since long, please guide.

Regards

library(rpivotTable)
rpivotTable(data = mtcars, subtotals = FALSE, rows = c( "cyl"),cols=c("carb"), vals = "mpg", aggregatorName = "Sum", rendererName = "Table", width="50%", height="550px")

enter image description here

Maurits Evers
  • 49,617
  • 4
  • 47
  • 68
Sid
  • 53
  • 8

4 Answers4

2

Subtotals can be removed presented on the 6th row below:

library(pivottabler)

pt <- PivotTable$new()

pt$addData(data)

pt$addColumnDataGroups("Date")  

pt$addRowDataGroups("SKU.ID" ,  addTotal=FALSE) 

pt$addRowDataGroups("Location" ,  addTotal=FALSE)

pt$renderPivot()

pt$defineCalculation(calculationName="Total Sales Qty", summariseExpression="sum(Sales_Qty, na.rm=TRUE)")

pt$defineCalculation(calculationName="TotalSalesQty")
pt$renderPivot()
Brett Gregson
  • 5,867
  • 3
  • 42
  • 60
Ummed_iitk
  • 31
  • 4
1

I got it working like this through CSS (a workaround since only the display is hidden):

mypivottable <- htmlwidgets::prependContent(mypivottable,
     htmltools::tags$style(
     ".pvtTotalLabel, .colTotal, .rowTotal, .pvtGrandTotal { display: none; }"
     )
  )

I dont think it works in Shiny app though.

szapiszapo
  • 11
  • 2
1

The solution from szapiszapo works for Shiny apps if you add tags$style( ".pvtTotalLabel, .colTotal, .rowTotal, .pvtGrandTotal { display: none; }" ) to the UI. e.g.

ui <- fluidPage(
    tags$style(
        ".pvtTotalLabel, .colTotal, .rowTotal, .pvtGrandTotal { display: none; }"
    ),
    rpivotTableOutput("pivot_table", height = "100%")
)
0

The current version of rPivottable doesn’t allow you to remove totals, but the next version likely will.

nicolaskruchten
  • 26,384
  • 8
  • 83
  • 101
  • Thanks nicolas, can you pls let me know when will the next version be available? – Sid Oct 27 '18 at 22:48
  • i want to ask you one more thing, the url of shiny app doesn't load, in log it says out of memory, i don't want to minimize my dataset, can you please suggest me a solution? – Sid Oct 27 '18 at 22:50
  • Hi Nicolas, i have 2 questions. 1) Can i hide totals if not delete? 2) Can i increase the width of drop downs? as some strings are big and unreadable in drop down unless scrolled to left – Sid Oct 29 '18 at 12:02