r - 使用 flextable 在表格的不同部分之间共享脚注
问题描述
我需要创建表,在表的标题和正文中都放置了相同的脚注,我无法弄清楚如何使用它来实现flextable
,我可以创建的内容如下:
library(flextable)
library(dplyr)
library(tidyr)
data(iris)
iris %>%
as_tibble %>%
gather(.,key = variable,value = value,-Species) %>%
group_by(Species,variable) %>%
summarise(value=formatC(mean(value),digits = 2,format = 'f')) %>%
ungroup %>%
spread(.,key = variable,value = value) %>%
flextable %>%
footnote(.,part = 'header',i = 1,j = c(2:5),
value = as_paragraph(c('Rounded to two decimal places')),
ref_symbols = c('*'),
inline=FALSE) %>%
footnote(.,part = 'body',i = c(1:3),j = 1,
value = as_paragraph(c('Rounded to two decimal places')),
ref_symbols = c('*'),
inline=FALSE)
目前我为页眉和正文创建了两个具有相同语句的脚注,我想知道是否可以将这两个语句合并为一个。
谢谢!
解决方案
(我没想到在实现此功能时会重复脚注,但是)使用merge_v
,如果相同,您可以合并它们:
library(flextable)
library(dplyr)
library(tidyr)
data(iris)
iris %>%
as_tibble %>%
gather(.,key = variable,value = value,-Species) %>%
group_by(Species,variable) %>%
summarise(value=formatC(mean(value),digits = 2,format = 'f')) %>%
ungroup %>%
spread(.,key = variable,value = value) %>%
flextable %>%
footnote(.,part = 'header',i = 1,j = c(2:5),
value = as_paragraph(c('Rounded to two decimal places')),
ref_symbols = c('*'),
inline=FALSE) %>%
footnote(.,part = 'body',i = c(1:3),j = 1,
value = as_paragraph(c('Rounded to two decimal places')),
ref_symbols = c('*'),
inline=FALSE) %>%
merge_v(part = "footer")
推荐阅读
- model-view-controller - 如何获取绑定到 MVC 中复杂对象列表的属性的复选框输入值?
- c++ - 如何摆脱 OpenCv 的 Bad argument 错误
- javascript - Unexpected token exporting async function
- mysql - MYSQL 使用 AND 和通配符
- java - 使用谓词作为单元测试的参数
- symfony - 自定义操作上的 api-platform 不需要的字段更新
- umbraco - 导入 Umbraco 属性编辑器
- c++ - 将顺序容器“移动”到指针
- php - 在字符串 PHP 数组上添加花括号
- html - 我无法渲染反应