0
我必须比较数据中的某些值并显示每周趋势。我想表明一个价值是否比上周有所增加。我已经创建了一个rmarkdown报告来做到这一点。示例代码如下所示,使用output: word_document
rmarkdown word文档中的HTML格式表
---
title: "trials"
author: "Foo Bar"
date: "15 December 2016"
output: word_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r cars, echo=FALSE, cache=FALSE, message=FALSE}
library(dplyr, quietly = TRUE)
library(abind, quietly = TRUE)
virginica <- iris %>% filter(Species == "virginica") %>% head() %>% select(-Species)
setosa <- iris %>% filter(Species == "setosa") %>% head() %>% select(-Species)
diff_mat <- virginica - setosa
diff_mat[diff_mat<0] <- '<font color="green">⇓ </font>'
diff_mat[diff_mat>0] <- '<font color="red">⇑ </font>'
diff_mat[diff_mat == 0] <- '<font color="blue">⇔ </font>'
datArray <- abind::abind(virginica, diff_mat, along=3)
fin_dat <- apply(datArray,1:2, function(x)paste(x[1],x[2], sep = " "))
knitr::kable(fin_dat, format = "html",
escape = FALSE, table.attr = "border=1",
caption = "Changes across species")
```
时如何设置格式类似于HTML版本的文档的话版本时output: html_document
但输出搞砸了这完美的作品?
也许试试'bookdown :: word_document2' – Ben