I kind of know the answer, which is render()
. However, when I render
the code below, the output is not consistent with the one that I would get by simply pressing knit
. In fact, the table is not rendered as expected from the function 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)
```
To call the renderer I use rmarkdown::render('testLookKable.Rmd', output_dir = 'standardReports/', runtime = 'static', output_format = 'pdf_document')
.
This is how the tables look like when I press the botton to knit to pdf:
And this is how to it looks like when I render()
by typing in the function
What I am trying to achieve is the first output, but rendering by explicitly running the function rather then pressing the botton.
From 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