Tiled formats using formatted in R

I would like to use color_tile

in a calculation based column instead of basing it on its own continuous scale. I have some code to format the text color in the following example:

library(formattable)

my.df <- data.frame(
   Type = c("A", "B", "C", "D", "E"),
   Count = c(5, 7, 3, 8, 4),
   Expect = c(2, 6, 3, 15, 0)
 )

formattable(my.df, list(
  Type = formatter("span",
                   style = ~style(color = ifelse(Count/Expect - 1 > .2, "red", 
    ifelse(Count/Expect - 1 < -.2, "green", "black")))
                   )

  ))

      

These are the colors I want, but instead of colored text, I would like to have tiles. I have not figured out how I can use color_tile

which is calculation based or based on something other than its own column values. Can I use tiles?

+3
r rstudio


source to share


No one has answered this question yet

Check out similar questions:

6
geom_tile single color as 0 then color scale
6
set color gamut for heatmap
five
Dendrogram edge (branch) colors to match apex (leaf) colors (ape package)
1
Conditional formatting of the background color of a table (formatted in R)
1
3D histogram in R: some problems
1
Plot multiple layers with ggplot2
0
R Formattable applies two formats to a region
0
combining widgets removes formatting
0
Conditional cell coloring in data frame using R
0
Can I manipulate the legend in ggplot by removing the icons and changing the text color?



All Articles
Loading...
X
Show
Funny
Dev
Pics