r - gt 测距列颜色填充
问题描述
这个问题来自这篇文章。
如何将红色和绿色的颜色范围从灰色到红色以及从灰色到绿色?我无法应用颜色范围。
有部分解决方案
library(gt)
library(tidyverse)
logistic_pattern <- function(...) {
args <- list(...)
x <- args[[1]]
thresholds <- args[[2]]
zeros <- numeric(length(x))
#sigma for normalizacion.
# maybe uniform sigma <- (pmax - pmin)/sqrt(12)
sigma <- 0.2
y <- 1/(1+exp(-(x - thresholds)/sigma))
y
}
gt(df) %>%
tab_style(
style = cell_fill(color = "gray85"),
locations = cells_body(
columns = c(name, performance),
rows = between(logistic_pattern(value, threshold), 0.45, 0.55)
)
) %>%
tab_style(
style = cell_fill(
# color = scales::col_bin(.$threshold, domain = colfunc(10))
color = "red"
),
locations = cells_body(
columns = c(name, performance),
rows = logistic_pattern(value, threshold) < 0.45
)
) %>%
tab_style(
style = cell_fill(
color = "green"
),
locations = cells_body(
columns = c(name, performance),
rows = logistic_pattern(value, threshold) > 0.55
)
)
我评论了一次失败的尝试,但它不喜欢 R,因为它们的尺寸。
# colfunc <- colfunc <- colorRampPalette(c("red", "gray85", "green"))
# color = scales::col_bin(.$threshold, domain = colfunc(10))
解决方案
推荐阅读
- node.js - Fetch 请求不返回数据
- java - 片段未在后退按钮上打开上一个片段
- java - 如何使用 CriteriaUpdate 编写联接?
- r - 具有相同名称但不同的两个匹配列的行平均值:'_1' 和 '_2'
- autodesk-forge - 使用 Autodesk BIM360 帐户登录 auth0
- kubernetes - 无法在 kubernetes 中编辑 configmap
- android - 尝试查找子片段时,getSupportFragmentManager findFragmentByTag 始终返回 null
- aws-lambda - 是否有在 AWS Lambdas 之间发送消息的好模式
- java - 运行后仰活动时出现错误
- php - 如何使用 Ajax 提交或发布 Csv 文件以及其他表单详细信息