Reputation: 3496
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
Upvotes: 0
Views: 358
Reputation: 263481
I was getting errors about pdflatex
not being found (despite multiple versions of found by locate
. After setting my current version of TexLive to 2016,
machine-name:~ username$ texdist —-current
machine-name:~ username$ pdflatex -v
# pdfTeX 3.14159265-2.6-1.40.17 (TeX Live 2016)
I still needed to do this (copied from an answer on 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
I now get sort of a combined version of your two images:
I had also edited PATH to remove the pre-El Cap item: usr/bin/texbin
and put in /Library/TeX/Distributions/.DefaultTeX/Contents/Programs/texbin:
. None of which worked. (I'm not using RStudio.)
Upvotes: 1