我觉得我错过了一些轻松的东西。祝你好运吧。
我试图在officedown中使用gt汇总和可弯曲的方法来生成表。我正在使用officedown中“高级word文档”模板中的yaml选项。
下面是我的密码。前两个表有下面的标题,第三个表在顶部,这是应该的!
R version 4.1.2 (2021-11-01)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)
attached base packages:
[1] stats graphics grDevices utils datasets methods
[7] base
other attached packages:
[1] flextable_0.6.10 forcats_0.5.1 stringr_1.4.0
[4] dplyr_1.0.7 purrr_0.3.4 readr_2.0.2
[7] tidyr_1.1.4 tibble_3.1.5 ggplot2_3.3.5
[10] tidyverse_1.3.1 gtsummary_1.5.0 palmerpenguins_0.1.0
[13] janitor_2.1.0 officer_0.4.1 officedown_0.2.3
---
date: "Last compiled on `r format(Sys.time(), '%d %B, %Y')`"
author: "Kristy Robledo"
title: "Table captions example"
output:
officedown::rdocx_document:
mapstyles:
Normal: ['First Paragraph']
---
```{r setup, include=FALSE}knitr::opts_chunk$set(echo = FALSE,fig.cap = TRUE)
图书馆(办公大楼)
图书馆(主任)
图书馆(掌企鹅)
图书馆(gtsummary摘要)
图书馆(Tidyverse)
图书馆(可弯曲)
## My tables
```{r,tab.id="peng" }企鹅%>%
tbl_summary(by=species) %>%
as_flex_table() %>%
Set_caption(“set_caption提供的可伸缩标题”)
```{r,tab.id="peng2", tab.cap="Caption by knitr" }企鹅%>%
tbl_summary(by=species) %>%
as_flex_table()
### Tables from example
```{r tab.cap="caption 1", tab.id="mtcars"}磁头(地铁)
## Reference
see table \@ref(tab:mtcars) for how I want it and these tables for underneath!
(table \@ref(tab:peng) and table \@ref(tab:peng2)!)发布于 2021-12-15 08:35:37
不是flextable和officedown方面的专家。但是,对我有用的一种选择是通过以下方式设置R标记文档表标题的位置
knitr::opts_chunk$set(tab.topcaption = TRUE)。
完全可复制代码:
---
date: "Last compiled on `r format(Sys.time(), '%d %B, %Y')`"
author: "Kristy Robledo"
title: "Table captions example"
output:
officedown::rdocx_document:
mapstyles:
Normal: ['First Paragraph']
---
```{r setup, include=FALSE}knitr::opts_chunk$set(echo = FALSE,fig.cap = TRUE)
图书馆(办公大楼)
图书馆(主任)
图书馆(掌企鹅)
图书馆(gtsummary摘要)
图书馆(Tidyverse)
图书馆(可弯曲)
```{r}knitr::opts_chunk$set(tab.topcaption = TRUE)
## My tables
```{r,tab.id="peng" }企鹅%>%
tbl_summary(by=species) %>%
as_flex_table() %>%
Set_caption(“set_caption提供的可伸缩标题”)
```{r, tab.id="peng2", tab.cap="Caption by knitr"}企鹅%>%
tbl_summary(by=species) %>%
as_flex_table()
### Tables from example
```{r tab.cap="caption 1", tab.id="mtcars"}磁头(地铁)
## Reference
see table \@ref(tab:mtcars) for how I want it and these tables for underneath!
(table \@ref(tab:peng) and table \@ref(tab:peng2)!)

https://stackoverflow.com/questions/70358796
复制相似问题