在 RMarkdown 中按下编织按钮相当于什么?

What's the equivalent of pressing the button knit in RMarkdown?

我知道答案是 render()。但是,当我 render 下面的代码时,输​​出与我通过简单地按 knit 得到的结果不一致。事实上,table 未按预期从函数 kable.

中呈现
---
title: "Untitled"
output:
  pdf_document: default
  html_document: default
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

## R Markdown
```{r results='asis'}
library(knitr)
library(dplyr)

print_kable <- function(species) {
        iris %>% filter(Species == species) %>% 
            summarise(avg=mean(Sepal.Width)) %>% 
            kable(caption=paste('Results for', species)) %>% print
        }

ff <- lapply(c("setosa", "versicolor", "virginica"), print_kable)

```

要调用我使用的渲染器 rmarkdown::render('testLookKable.Rmd', output_dir = 'standardReports/', runtime = 'static', output_format = 'pdf_document')

这是 table 按下按钮编织成 pdf 时的样子:

这就是我 render() 输入函数

时的样子

我想要实现的是第一个输出,但是通过显式 运行 函数渲染而不是按下按钮。

来自sessionInfo()

R version 3.4.0 (2017-04-21)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Sierra 10.12.4
rmarkdown_1.5
knitr_1.15.1 

我收到有关 pdflatex 未找到的错误(尽管 locate 找到了多个版本)。将我当前的 TexLive 版本设置为 2016 后,

machine-name:~ username$  texdist —-current
machine-name:~ username$  pdflatex -v
# pdfTeX 3.14159265-2.6-1.40.17 (TeX Live 2016)

我仍然需要这样做(从 SO 上的答案复制):

 sudo ln -fhs Distributions/.DefaultTeX/Contents/Programs/texbin /Library/TeX/texbin
 echo "/Library/TeX/texbin" >~/Desktop/TeX
 sudo cp ~/Desktop/TeX /etc/paths.d/TeX
 echo "/Library/TeX/Distributions/.DefaultTeX/Contents/Man" >~/Desktop/TeX
 sudo cp ~/Desktop/TeX /etc/manpaths.d/TeX
 echo /Library/TeX/texbin

我现在得到了你的两张图片的组合版本:

我还编辑了 PATH 以删除 pre-El 上限项:usr/bin/texbin 并放入 /Library/TeX/Distributions/.DefaultTeX/Contents/Programs/texbin:。 None 其中有效。 (我没有使用 RStudio。)