我使用来生成HTML报告。我在受限制的机器上,无法安装tex。所以,我试图生成一个HTML文档,然后将其转换/打印为pdf。这个例子降价文件是:在html中将html保存为pdf
---
title: "trials"
author: "Foo Bar"
date: "15 December 2016"
output: html_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 formatted tables in rmarkdown word document讨论的格式都将丢失。生成的HTML正是我想要的。使用保存在Word中的HTML语言大多数都可以处理,但我可以打印PDF,但不如直接从PDF打印。
当我尝试将其保存为PDF格式的PDF时,颜色丢失。
有一个在打印选项没有任何问题 如我们敬爱的网站Replace NA's using data from Multiple Columns打印精细
其他网页你有任何指针哪里我错过了一个观点或问题出在哪里。
谢谢!这是我在SO中读到的最深入的答案之一。 – discipulus