gpt4 book ai didi

r - flextable 中有条件的粗体值

转载 作者:行者123 更新时间:2023-12-05 09:30:16 28 4
gpt4 key购买 nike

是否可以根据 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)

enter image description here

关于r - flextable 中有条件的粗体值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69782546/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com