title: How can I set a gradient color shade in DT::datable colums?
body: <p>I've got a shiny App where I want to fill numeric column spaces of a matrix output with different colors from low to high according each row value (all of them but 'topic'). I saw <a href="https://rstudio.github.io/DT/functions.html" rel="nofollow noreferrer">in this link</a> a way to color spaces with <code>color = styleInterval()</code> but I can't figure out a way to fit different colors for each column by topic (taking into account that they won't necesarilly be the same number of topics each time, but they won't ever be more than 15 topics for sure &amp; of course numbers of each column will vary). Important to mention that I want the same colors for each one of those other 3 numeric columns, gradient according to respective values. Could somebody please tell me the way?</p>
  
  <pre><code># --------------------------------------- Global --------------------------------------- #
  
  #1. App
  if("shiny" %in% rownames(installed.packages()) == FALSE){ install.packages("shiny") }
  library(shiny)
  
  #3. Easier data handling
  if("dplyr" %in% rownames(installed.packages()) == FALSE){ install.packages("dplyr") }
  library(dplyr)
  
  #8. Data Table shiny outputs 
  if("DT" %in% rownames(installed.packages()) == FALSE){ install.packages("DT") }
  library(DT)
  
  #--------------------------------------- User Interface ---------------------------------------#
  ui &lt;- fluidPage( 
    DT::dataTableOutput("topic_info_table")
    )
  
  #--------------------------------------- Server ---------------------------------------#
  
  server &lt;- function(input, output, session) {
  # COLOR TABLE BY TOPIC
  
  bytopic &lt;- NULL
  
  output$topic_info_table &lt;- DT::renderDataTable({
  
    bytopic &lt;- structure(c("Chocolate", "Pineapple", "Coconut", "Jam", "Jelly", 
                          "Soup", "Ice-Cream", "Cake", "Pudin", "Candy", "Pizza", "Rum", 
                          "Vodka", "2016", "2016", "2017", "2016", "2016", "2018", "2016", 
                          "2017", "2016", "2016", "2016", "2017", "2017", "2034", "2036", 
                          "2036", "2029", "2035", "2036", "2035", "2033", "2035", "2035", 
                          "2035", "2034", "2037", "14030.57", "13488.00", "12402.98", "16053.32", 
                          "13256.43", "11388.83", "12005.04", "13691.61", "13161.59", "12605.35", 
                          "12348.48", "12872.83", "10963.04"), .Dim = c(13L, 4L), .Dimnames = list(
                            c("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", 
                              "12", "13"), c("topic", "year", "expiration", "cost")))
  
    DT::datatable(bytopic, options = list(pageLength = 15)) %&gt;% formatCurrency(c('cost')) 
  }) 
  }
  shinyApp(ui,server)
  </code></pre>
  
  <hr>
  
  <p>Idea would be getting something like:
   <a href="https://i.stack.imgur.com/XFHSR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XFHSR.png" alt="this"></a>
  Easily done with Excel's <code>conditional formating</code> where you format cells based on their values. In the example I used the clearest green shade for minimum value to the darkest blue shade for the maximum. Hopefully with a legend that says something like Lowest -> Highest with the color gradient.</p>