首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使word_document输出中的边框宽度具有可弯曲性?减缩

如何使word_document输出中的边框宽度具有可弯曲性?减缩
EN

Stack Overflow用户
提问于 2021-12-14 20:11:51
回答 3查看 908关注 0票数 2

我在Rmarkdown中使用flextable()来创建表。我将代码编织到word_document输出中。有没有人知道如何将表的宽度与word_document输出中的边框宽度相匹配,而不是将其与内容相匹配?

代码语言:javascript
复制
---
title: ""
output: word_document
---

```{r setup, include=FALSE}

knitr::opts_chunk$set(echo =真)

图书馆(可弯曲)

图书馆(Dplyr)

代码语言:javascript
复制
## R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.

When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

```{r cars}

头(Cars)%>%

柔性()%>%

theme_box()%>%

自动装配()

代码语言:javascript
复制

下面我附上两张照片:

  • 第一个-我的代码产生了什么,

  • 第二个-我想要生产的东西

谢谢!

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2021-12-16 06:13:50

基于word_document输出中列内容和边边框拟合列宽的解决方案

代码语言:javascript
复制
---

title: ""
output: word_document
---

```{r setup, include=FALSE}

knitr::opts_chunk$set(echo =真)

图书馆(可弯曲)

图书馆(Dplyr)

代码语言:javascript
复制
## R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.


```{r cars}

I= word_document输出中边框的16.5 #宽度(厘米)

W= i*0.3937 #边框宽度在word_document输出中(以英寸为单位)

df <- data.frame('model‘=行名(Mtcar),mtcars 1:5)

T<-可弯曲(头(df,3))

没有安装的桌子,所有的科尔都有相同的基座宽度。

t<-autofit(t)

T#自动安装,cols具有基于col含量的宽度。

#从自动安装表中获取列宽比例

auto_widths <- dim(T)$宽度/sum(dim(T)$widths)

word_document输出中基于col内容和边边框的拟合宽度

T<-宽度(t,width=w*auto_widths)

T

代码语言:javascript
复制

票数 0
EN

Stack Overflow用户

发布于 2021-12-14 22:27:31

听着,那里,David为这个任务做了一个很好的函数:)

给您举一个例子:

代码语言:javascript
复制
```{r cars}

头(Cars) %>%

柔性%>%

宽度(.,宽度= 3.35) %>%

theme_box()

代码语言:javascript
复制

票数 1
EN

Stack Overflow用户

发布于 2021-12-15 05:11:29

基于芒洛解决方案,无论表中有多少列,我都编写了一个代码,该代码生成一个具有给定宽度的表。这也是我的目标,我可能在我的问题中没有清楚地解释。

代码语言:javascript
复制
```{r cars}

I= word_document输出中边框的16.5 #宽度(厘米)

W= i*0.3937 #边框宽度在word_document输出中(以英寸为单位)

代码语言:javascript
复制
# Table 1 with 2 columns 
代码语言:javascript
复制
head(cars,3) %>% 
代码语言:javascript
复制
  flextable %>%
代码语言:javascript
复制
  width(., width = (w/(ncol(cars)))) %>% 
代码语言:javascript
复制
  theme_box() 
代码语言:javascript
复制
# Table 2 with 5 columns
代码语言:javascript
复制
head(iris,3) %>% 
代码语言:javascript
复制
  flextable %>%
代码语言:javascript
复制
  width(., width = (w/(ncol(iris)))) %>% 
代码语言:javascript
复制
  theme_box() 
代码语言:javascript
复制

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70355001

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档