我使用來生成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