Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Flextable to Word获取自由文本调查响应_R_R Markdown_Rendering_Flextable - Fatal编程技术网

使用Flextable to Word获取自由文本调查响应

使用Flextable to Word获取自由文本调查响应,r,r-markdown,rendering,flextable,R,R Markdown,Rendering,Flextable,我正在做一些调查分析,遇到了一个奇怪的问题 当我试图将flextable对象写入Word时,得到的是一个约30页的空白文档。这以前在R和R降价中没有任何问题,我不明白为什么会发生这种情况 以下是dput: df <- structure(list(Response = c("Comment from patron 1", "Comment from customer 2", "Comment from someone 3", "Comment from nobody 4", "Comme

我正在做一些调查分析,遇到了一个奇怪的问题

当我试图将
flextable
对象写入Word时,得到的是一个约30页的空白文档。这以前在R和R降价中没有任何问题,我不明白为什么会发生这种情况

以下是dput:

df <- structure(list(Response = c("Comment from patron 1", "Comment from customer 2", 
"Comment from someone 3", "Comment from nobody 4", "Comment from patron 5", 
"Comment from customer 6", "Comment from someone 7", "Comment from nobody 8"
)), row.names = c(NA, -8L), class = c("tbl_df", "tbl", "data.frame"
))

df正如David Gohel所提到的,添加一个宽度参数解决了这个问题:

ft <- as.data.frame(df)
ft <- flextable(ft)
ft <- theme_zebra(ft)
ft <- autofit(ft)
**ft <- width(ft, width = 7)**

doc <- read_docx()
doc <- body_add_flextable(doc, value = ft)
print(doc, target = "Doc2.docx")

ft您好,很确定它与。解决方法:在具有巨大宽度的列上添加一个合理的补丁widtth。请注意,我认为您是在Windows上,因为它不会出现在其他系统上。谢谢,@DavidGohel。这就解决了问题。另外,感谢您为维护flextable所做的一切—这是一个了不起的软件包!
ft <- as.data.frame(df)
ft <- flextable(ft)
ft <- theme_zebra(ft)
ft <- autofit(ft)
**ft <- width(ft, width = 7)**

doc <- read_docx()
doc <- body_add_flextable(doc, value = ft)
print(doc, target = "Doc2.docx")