[英]conditionally bold values in flextable
是否可以根据 tstat.粗体/颜色估计值?
例如,如果 tstat 大于 1.96,则为粗体估计值
library(dplyr)
library(flextable)
attribute <- c("b0", "b1", "b2", "b3", "b4", "b5")
estimate <- round(runif(n = 6, min = 0, max = 5), 2)
tstat <- round(runif(n = 6, min = 0, max = 5), 2)
# tibble
tbl <- tibble(attribute, estimate, tstat) %>%
as_flextable()
另一种解决方案:
library(dplyr)
library(flextable)
set.seed(4123)
attribute <- c("b0", "b1", "b2", "b3", "b4", "b5")
estimate <- round(runif(n = 6, min = 0, max = 5), 2)
tstat <- round(runif(n = 6, min = 0, max = 5), 2)
tbl <- tibble(attribute, estimate, tstat)
tbl %>%
flextable() %>%
bold(tbl$tstat > 1.96,2)
使用 flextable行选择器的另一种解决方案:
library(dplyr)
library(flextable)
set.seed(4123)
attribute <- c("b0", "b1", "b2", "b3", "b4", "b5")
estimate <- round(runif(n = 6, min = 0, max = 5), 2)
tstat <- round(runif(n = 6, min = 0, max = 5), 2)
tbl <- tibble(attribute, estimate, tstat)
tbl %>%
flextable() %>%
bold(~ tstat > 1.96,2)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.