[英]How colorized cells from “green” to “red” in R interface to the DataTables?
有一個很好的例子: https://rstudio.github.io/DT/010-style.html顏色值范圍從“white”到“redrg2”
library(DT)
# 1. Data
df = as.data.frame(cbind(matrix(round(rnorm(50), 3), 10), sample(0:1, 10, TRUE)))
# 2. Create 19 breaks and 20 rgb color values ranging from white to red
brks <- quantile(df, probs = seq(.05, .95, .05), na.rm = TRUE)
clrs <- round(seq(255, 40, length.out = length(brks) + 1), 0) %>%
{paste0("rgb(255,", ., ",", ., ")")}
# 3. DT
datatable(df) %>% formatStyle(names(df), backgroundColor =
styleInterval(brks, clrs))
但是如何從“綠色”到“紅色”進行相同的着色?
謝謝!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.