如何从Flextable中导出表格,以使其与Rstudio查看器的外观匹配

发布于 2025-02-01 11:49:19 字数 626 浏览 2 评论 0原文

我正在使用RSTUDIO中的Flyxable软件包将我的R输出作为表格导出到Word文档上。

该桌子在观看者上看起来不错:

​net/hdnnr.png“ rel =“ nofollow noreferrer”>

” 've二手:

library(flextable)

table <- flextable(fct_count(a2, prop=TRUE))

table <- set_header_labels(table,
                        values = list(f = "Category") )

table <- theme_vanilla(table)
table <- autofit(table)

table

save_as_docx(
  "my table 1" = table, 
  path = "/path/to/file.docx")

请帮助我弄清楚如何导出,以便它看起来像在观众身上一样。提前致谢。

I'm using the flextable package in RStudio to export my R output as a table onto a word document.

The table looks fine on the viewer:

The table looks fine on the viewer:

However, when I try to export this onto a word document it looks like this:

enter image description here

Here is the script I've used:

library(flextable)

table <- flextable(fct_count(a2, prop=TRUE))

table <- set_header_labels(table,
                        values = list(f = "Category") )

table <- theme_vanilla(table)
table <- autofit(table)

table

save_as_docx(
  "my table 1" = table, 
  path = "/path/to/file.docx")

Please help me figure out how to export so that it looks as it does on the viewer. Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

无人接听 2025-02-08 11:49:19

如果没有可再现的例子,很难提供帮助。我会使用宽度功能,直到它按照我的需求运行为止。例如 :

table <- width(table, j = c(1,3), width = c(2,4))

Difficult to help without a reproducible example. I would play with width function until it works as I want. For example :

table <- width(table, j = c(1,3), width = c(2,4))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文