You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
removeAllColumnGroups <- function(pt)
{
while(pt$columnGroup$childGroupCount > 0) {
pt$columnGroup$removeChildGroup(index=pt$columnGroup$childGroupCount)
}
}
pt <- PivotTable$new()
pt$addData(bhmtrains)
pt$addColumnDataGroups("TrainCategory")
pt$addRowDataGroups("TOC")
pt$defineCalculation(calculationName="TotalTrains", summariseExpression="n()")
pt$renderPivot()
removeAllColumnGroups(pt)
pt$renderPivot()
# need to reapply the calculations as those cells have been lost
pt$addColumnDataGroups("TrainCategory")
pt$defineCalculation(calculationName="TotalTrains", summariseExpression="n()")
pt$renderPivot()
Is there an easy way to clear the cells from the pivot table (to allow the rows and columns to be amended) then reapply the calculations (on the same axis as they were originally applied, in the same order?)
Or is all this just too complicated and not worth doing?
For background, see:
https://stackoverflow.com/questions/62452034/can-we-replace-a-column-from-a-pivot-table-created-using-pivottabler-package
Example that doesn't work:
Is there an easy way to clear the cells from the pivot table (to allow the rows and columns to be amended) then reapply the calculations (on the same axis as they were originally applied, in the same order?)
Or is all this just too complicated and not worth doing?
Consider adding pt$clearColumnGroups(), pt$clearRowGroups().
The text was updated successfully, but these errors were encountered: