title: conditionally format dynamically created table in R
body: <p>I would like to render a table in R, with cells formatted according to some  non-trivial logic.  (e.g. if a value is odd, color the cell yellow; if it is also >5, make the text bold, etc.).  This logic would be applied to each column of a dynamically created table, i.e. the column names are unknown so cannot be used in the code.</p>
  
  <p>If found <a href="https://stackoverflow.com/questions/26174601/r-shiny-table-conditional-formatting-within-renderui">this</a> JQuery approach helpful, but I'm not sure it completely solves my problem, plus I would prefer an R-based approach.</p>
  
  <p>I also came close using the <a href="https://cran.r-project.org/web/packages/condformat/vignettes/introduction.html" rel="nofollow noreferrer">condformat</a> package, but for some reason the following doesn't work:</p>
  
  <pre><code>library(condformat)
  data(iris)
  
  # Create a condformat object
  cf &lt;- condformat(iris)
  
  # Add rules to it:
  for (col in colnames(iris)[1:2]) {
    cf &lt;- cf %&gt;% rule_css(!!col, 
  expression = ifelse(eval(parse(text=col)) &lt; 3.3, "red", "black"),
  css_field = 'color')
  }
  # Render it
  cf
  </code></pre>
  
  <p>The first column of the resulting table doesn’t abide by the rule; instead, it is given the colors from column 2.  But if I instead loop over just that first column, the coloring for it is correct.</p>
  
  <p>Any help with the above code, or with the problem generally, would be greatly appreciated.</p>