是否可以根据 tstat 对估计值进行加粗/着色。
对于 ex - 如果 tstat 大于 1.96 则粗体估计值
这是 my previous question 的延续我必须使用 flextable。
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(~ tstat > 1.96,2)
https://stackoverflow.com/questions/69782546/