R:呈现可伸缩性

R:呈现可伸缩性,r,knitr,xtable,R,Knitr,Xtable,我有一个.Rmd文件,其中包含: ```{r, echo=FALSE, message=FALSE, results='asis'} library(xtable) print(xtable(groupGrundALL)) ``` 使用RStudio中的“Knit Word”按钮创建并打开Word文件,但仅显示以下文本行,而不是预期的(渲染的)表格本身: %2015年10月11日星期三:14:28,XTTable 1.7-4软件包在R 3.2.2中生成的乳胶表% 当我在控制台中运行时

我有一个.Rmd文件,其中包含:

```{r, echo=FALSE, message=FALSE, results='asis'}
library(xtable)
print(xtable(groupGrundALL))  
```  
使用RStudio中的“Knit Word”按钮创建并打开Word文件,但仅显示以下文本行,而不是预期的(渲染的)表格本身:

%2015年10月11日星期三:14:28,XTTable 1.7-4软件包在R 3.2.2中生成的乳胶表%

当我在控制台中运行时

library(xtable)
print(xtable(groupGrundALL)) 
我得到一个密码:

% latex table generated in R 3.2.2 by xtable 1.7-4 package
% Wed Oct 21 11:16:48 2015
\begin{table}[ht]
\centering
\begin{tabular}{rlrrr}
\hline
& Retouren.Grund & Wert & Menge & Anzahl \\ 
\hline
1 & Fehlbestellung & 685395.00 & 11469.00 & 222 \\ 
2 & andere & 237581.00 & 4354.00 & 179 \\ 
3 & Abgelaufene Ware & 129780.00 & 3522.00 & 1077 \\ 
4 & beschädigte Ware & 37417.00 & 729.00 & 143 \\ 
5 & Falschlieferung & 9943.00 & 280.00 &  14 \\ 
6 & nicht abgeholt & 1471.00 & 21.00 &  11 \\ 
7 & weggezogen & 25.00 & 1.00 &   1 \\ 
\hline
\end{tabular}
\end{table}
如何在Word文档中呈现和显示表格本身


非常感谢你的帮助

据我所知,
xtable
仅支持HTML和LaTeX格式(默认为LaTeX)。如果要将文档呈现为Word文件,则需要以标记格式传递表。至于现在该做什么的选项,这里有一些您可以考虑的(作为适合您的降价文档的代码):

如果连接到Word文档:

---
title: "Sample Document"
output: word_document
---

```{r}
groupGrundALL <- 
  structure(list(Retouren.Grund = structure(c(5L, 2L, 1L, 3L, 4L, 
6L, 7L), .Label = c("Abgelaufene Ware", "andere", "beschadigte Ware", 
"Falschlieferung", "Fehlbestellung", "nicht abgeholt", "weggezogen"
), class = "factor"), Wert = c(685395, 237581, 129780, 37417, 
9943, 1471, 25), Menge = c(11469, 4354, 3522, 729, 280, 21, 1
), Anzahl = c(222, 179, 1077, 143, 14, 11, 1)), .Names = c("Retouren.Grund", 
"Wert", "Menge", "Anzahl"), row.names = c(NA, -7L), class = "data.frame")
```

## `knitr::kable` 
```{r, echo=FALSE, message=FALSE, results='asis'}
knitr::kable(groupGrundALL, format = "markdown")
```  

## `pixiedust`
For markdown tables, `pixiedust` is an extended wrapper for `knitr::kable` that allows you to do some additional formatting without having to preprocess data.

```{r, warning = FALSE}
library(pixiedust)
dust(groupGrundALL) %>%
  sprinkle_print_method("markdown")
```

我对pixiedust(显然)有强烈的偏见,但是对于不需要太多定制的简单降价表,
knitr::kable
可能是最快的方法。

太好了!克尼特:卡布尔为我做了这项工作,但现在我将了解你奇妙的小精灵套装。。。很快将发布一个问题:-)更新:
Grmd
现已集成到
Gmisc
,可在CRAN上获得。
---
title: "Sample Document 2"
output: Grmd::docx_document
---


```{r}
groupGrundALL <- 
  structure(list(Retouren.Grund = structure(c(5L, 2L, 1L, 3L, 4L, 
6L, 7L), .Label = c("Abgelaufene Ware", "andere", "beschadigte Ware", 
"Falschlieferung", "Fehlbestellung", "nicht abgeholt", "weggezogen"
), class = "factor"), Wert = c(685395, 237581, 129780, 37417, 
9943, 1471, 25), Menge = c(11469, 4354, 3522, 729, 280, 21, 1
), Anzahl = c(222, 179, 1077, 143, 14, 11, 1)), .Names = c("Retouren.Grund", 
"Wert", "Menge", "Anzahl"), row.names = c(NA, -7L), class = "data.frame")
```

## `xtable` with HTML
```{r, echo=FALSE, message=FALSE, results='asis'}
library(xtable)
print(xtable(groupGrundALL), type = "html")  
```  

## `knitr::kable` 
```{r, echo=FALSE, message=FALSE, results='asis'}
knitr::kable(groupGrundALL, format = "html")
```  

## `pixiedust` with HTML
```{r, warning = FALSE}
library(pixiedust)
dust(groupGrundALL) %>%
  sprinkle_print_method("html")
```