Converting pivotr table to have custom formatting


I am looking for a simple way to take the below pivot table called tab and adding either a heatmap or some row bars unto the table. I am not sure how best to do this as I don't really want to redraw the whole output into DT and then render it. Any ideas?


tab <- pivotr(diamonds, cvars = c("clarity", "cut", "color"), nvar = "price", fun = "mean") %>% 

If you were making a shinyapp, you would simply place the two objects in the UI as desired, similarly if you were making rmarkdown you could place one chunk above the other.
Therefore I'm assuming that you want a single widget, a library is available that provides that.
I prefer to use renv to handle my installs, and only the dev version of the manipulateWidget library seems to support DT tables so...


tab <- pivotr(diamonds, cvars = c("clarity", "cut", "color"), nvar = "price", fun = "mean") %>% 

#l ibrary(renv)
# renv::install("FrancoisGuillem/manipulateWidget")
(mytwo <- manipulateWidget::combineWidgets(tab,tab,nrow=2,byrow=TRUE))

Hello @nirgrahamuk,

Thanks for the reply! I want to use the pivotr in Shiny however I want to be able to the conditional formating over that specific table. I am hoping that depending on the structure or object type tab is that I can simply pipe into something else or slightly adjust it to have that formatting added to it. I do not want to have 2 of the same tables on the UI. It definitely needs to be one.

I used the table twice just to show two things can be combined as a single widget, but this would seem to be uneccesary if you are happy to use shiny.

I guess I'm struggling to visualise what adding a heatmap to the table would look like.
Its a tiny heatmap that appears in cells of a row or column of the table ?

Ah sorry for not making it clear! Here is a link of what I want to achieve: If you look at 3 Style A Full Table you will see the two types of formatting I'd like to apply over mine.

If you look at the pivot table here: you will also see it is possible (though not exactly sure how they are doing it here)


tab <- pivotr(diamonds, cvars = c("clarity", "cut", "color"), nvar = "price", fun = "mean") %>% 

The documentation is at ?dtab.pivotr

## S3 method for class 'pivotr'
  format = "none",
  perc = FALSE,
  dec = 3,
  searchCols = NULL,
  order = NULL,
  pageLength = NULL,

Show Color bar ("color_bar"), Heat map ("heat"), or None ("none")

1 Like

Oh my...I feel so silly :see_no_evil: . Thank you for the help!

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