I'm new to targets ecosystem. I could not create a distill article from my targets pipeline although it works when I set the output to html_document in yaml. I have tried googling but couldn't find anything useful. Any help would be appreciated.
My RStudio is version 1.4.1717. I got this error message upon running tar_make():
Error: callr subprocess failed: Distill articles cannot be previewed in this version of RStudio.
Please update to version 1.2.718 or higher at https://www.rstudio.com/products/rstudio/download/
Visit https://books.ropensci.org/targets/debugging.html for debugging advice.
Run `rlang::last_error()` to see where the error occurred.
Here is a minimal code example.
Code in _targets.R
library(targets)
library(tarchetypes)
tar_plan(
tar_target(dat, iris),
tar_render(test_report, "test.Rmd")
)
Here are the contents of my Rmd file. Most of them are from the template.
---
title: "Test"
description: |
A new article created using the Distill format.
author:
- name: Nora Jones
url: https://example.com/norajones
affiliation: Spacely Sprockets
affiliation_url: https://example.com/spacelysprokets
date: "`r Sys.Date()`"
output: distill::distill_article
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
```{r load-targets, include=FALSE}
tar_load(dat)
```
```{r}
summary(dat)
```
Session info
R version 4.1.0 (2021-05-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)
Matrix products: default
locale:
[1] LC_COLLATE=English_United Kingdom.1252 LC_CTYPE=English_United Kingdom.1252
[3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C
[5] LC_TIME=English_United Kingdom.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] igraph_1.2.6 rstudioapi_0.13 knitr_1.33 magrittr_2.0.1 tidyselect_1.1.1
[6] R6_2.5.1 rlang_0.4.11 fansi_0.5.0 tools_4.1.0 targets_0.7.0
[11] data.table_1.14.0 xfun_0.25 utf8_1.2.2 cli_3.0.1 withr_2.4.2
[16] ellipsis_0.3.2 yaml_2.2.1 digest_0.6.27 tibble_3.1.3 lifecycle_1.0.0
[21] crayon_1.4.1 processx_3.5.2 purrr_0.3.4 callr_3.7.0 vctrs_0.3.8
[26] ps_1.6.0 codetools_0.2-18 glue_1.4.2 compiler_4.1.0 pillar_1.6.2
[31] pkgconfig_2.0.3
I've been having the same issue.
From here you can see that distill checks for the version first by trying the rstudioapi (which fails) and then by looking for an environment variable called "RSTUDIO_VERSION", which does not exist on my system. When this fails, it uses a default value of 1.1, which fails the check of having at least version 1.2.7...
There is a simple, if slightly hacky, solution which is to just manually set the environment variable that distill is looking for at the top of your script. I.e., your Rmd file would become:
---
title: "Test"
description: |
A new article created using the Distill format.
author:
- name: Nora Jones
url: https://example.com/norajones
affiliation: Spacely Sprockets
affiliation_url: https://example.com/spacelysprokets
date: "`r Sys.Date()`"
output: distill::distill_article
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
# Add environment variable
Sys.setenv("RSTUDIO_VERSION" = '1.4.1725')
```
```{r load-targets, include=FALSE}
tar_load(dat)
```
```{r}
summary(dat)
```
This works totally fine for me. If you're worried about this having ongoing effects, you can remove it afterwards (Sys.unsetenv("RSTUDIO_VERSION"))
Related
My Problem
I've been using seamlessly R's bookdown for a couple of weeks now until I've encountered the following error when running it's default template (skeleton) in RStudio:
output file: _main.knit.md
! Paragraph ended before \MT#prot#l was complete.
<to be read again>
\par
l.141
Error: LaTeX failed to compile _main.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See _main.log for more info.
Execution halted
Error: bookdown::render_book() failed to render the output format 'bookdown::pdf_book'.
Execution halted
Exited with status 1.
My Initial Diagnosis
The html version bookdown::gitbook() is still working! When I commented-out as follows the bookdown::pdf_book() portion in the _output.yml file, the book rendered with all the LaTeX equations. Moreover, bookdown::epub_book() still also works.
bookdown::gitbook:
css: style.css
config:
toc:
before: |
<li>A Minimal Book Example</li>
after: |
<li>Published with bookdown</li>
edit: https://github.com/USERNAME/REPO/edit/BRANCH/%s
# download: ["pdf", "epub"]
# bookdown::pdf_book:
# includes:
# in_header: preamble.tex
# latex_engine: xelatex
# citation_package: natbib
# keep_tex: yes
# bookdown::epub_book: default
I have resintalled RStudio, R, Rtools (with path included) TinyTex and updated everything as suggested in https://yihui.org/tinytex/r/#debugging but still of no avail.
My _main.log File
For reference, my _main.log file is here: https://github.com/rvcuenca/default_bookdown_template/blob/main/_main.log
My sessionInfo()
R version 4.1.2 (2021-11-01)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] rstudioapi_0.13 knitr_1.36.9 magrittr_2.0.1 usethis_2.1.5 gert_1.4.3
[6] R6_2.5.1 rlang_0.4.12 fastmap_1.1.0 fansi_0.5.0 httr_1.4.2
[11] tools_4.1.2 sys_3.4 xfun_0.28.10 utf8_1.2.2 cli_3.1.0
[16] withr_2.4.3 gitcreds_0.1.1 htmltools_0.5.2 askpass_1.1 ellipsis_0.3.2
[21] rprojroot_2.0.2 openssl_1.4.5 yaml_2.2.1 digest_0.6.29 tibble_3.1.6
[26] lifecycle_1.0.1 crayon_1.4.2 bookdown_0.24.4 purrr_0.3.4 vctrs_0.3.8
[31] fs_1.5.2 credentials_1.3.2 curl_4.3.2 glue_1.5.1 evaluate_0.14
[36] rmarkdown_2.11.3 gh_1.3.0 pillar_1.6.4 compiler_4.1.2 jsonlite_1.7.2
[41] pkgconfig_2.0.3
My Question
Any thoughts where could have I went wrong?
I get a compiling error when trying to render an R markdown script as pdf.
Knitting the markdown file with content below with the knit button in RStudio, or running the command knitr::knit('test.Rmd'), gives an error.
---
title: "Untitled"
output: pdf_document
---
##
```{r}
mod <- lm(speed ~ dist, data=cars)
jtools::summ(mod)
```
The error message I get is:
! LaTeX Error: Undefined color `gray!6'.
Note that when load the latex package xcolor in the preamble (as below) I get another error message but at least it compiles and renders a pdf.
---
title: "Untitled"
output:
pdf_document:
extra_dependencies: ["xcolor"]
---
##
```{r}
mod <- lm(speed ~ dist, data=cars)
jtools::summ(mod)
```
I get the same error when compiling a report from an R script. Note that I'm asking students to compile a report for a class exercise, so I don't want to lose them by having them play around with additional latex packages.
Also, apologies if this is the wrong forum, but because it's specific to an R package (things render to pdf just fine in general), it seemed like the right place for this question.
Below is my sessionInfo() in case this is helpful.
R version 4.0.2 (2020-06-22)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.5 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1
locale:
[1] LC_CTYPE=en_CA.UTF-8 LC_NUMERIC=C LC_TIME=en_CA.UTF-8 LC_COLLATE=en_CA.UTF-8 LC_MONETARY=en_CA.UTF-8
[6] LC_MESSAGES=en_CA.UTF-8 LC_PAPER=en_CA.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_CA.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] Rcpp_1.0.5 rstudioapi_0.11 knitr_1.29 magrittr_1.5 tidyselect_1.1.0 munsell_0.5.0 colorspace_1.4-1 R6_2.4.1
[9] rlang_0.4.7 dplyr_1.0.1 tools_4.0.2 grid_4.0.2 gtable_0.3.0 xfun_0.16 htmltools_0.5.0 ellipsis_0.3.1
[17] yaml_2.2.1 digest_0.6.25 tibble_3.0.3 lifecycle_0.2.0 crayon_1.3.4 purrr_0.3.4 ggplot2_3.3.2 jtools_2.1.0
[25] vctrs_0.3.2 glue_1.4.1 evaluate_0.14 rmarkdown_2.3 pander_0.6.3 compiler_4.0.2 pillar_1.4.6 generics_0.0.2
[33] scales_1.1.1 pkgconfig_2.0.3
I followed the "LaTeX packages used in this package" section in kableExtra's awesome_table_in_pdf vignette.
header-includes:
- \usepackage{xcolor}
It wasn't necessary when I knitted the document normally through RStudio. But it was when I had to do some unconventional things with a shared drive. (That's when I got the "! LaTeX Error: Undefined color `gray!6'." error.)
Complete yaml header:
title: SO Question
output:
pdf_document:
toc: FALSE
number_sections: TRUE
geometry: margin=2cm
header-includes:
- \usepackage{xcolor}
I'm trying to type up some statistics notes for one of my classes in bookdown. bookdown is not rendering the text written for any chapter with subsections. There is a bunch of text within each subsection, but it is not showing up when I compile to pdf.
Any ideas about what could be causing the problem?
The only thing that shows up is the section headers for the chapter. Sometimes deleting the files in _book is a workaround, but I can't reproduce the error easily. Everything seems to work, then I add a little text, and then I have the rendering problem. The document seems to compile with no warnings. A screenshot of the what I'm getting is included.
I'm running the most current version of RStudio.
Session info:
R version 3.6.1 (2019-07-05)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18362)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics
[3] grDevices utils
[5] datasets methods
[7] base
loaded via a namespace (and not attached):
[1] compiler_3.6.1
[2] bookdown_0.13.2
[3] htmltools_0.3.6
[4] tools_3.6.1
[5] yaml_2.2.0
[6] Rcpp_1.0.2
[7] rmarkdown_1.15
[8] knitr_1.25
[9] xfun_0.9
[10] digest_0.6.20
[11] packrat_0.5.0
[12] evaluate_0.14
My yaml header is:
title: "A Book"
author: "Frida Gomam"
site: bookdown::bookdown_site
documentclass: book
output:
bookdown::pdf_book:
includes:
in_header: preamble-latex.tex
# bookdown::gitbook:
# includes:
# before_body: preamble-mathjax.tex
bibliography: [book.bib]
biblio-style: apalike
You should click the Build Book button, instead of the Knit button. The latter only previews the current chapter. See documentation here: https://bookdown.org/yihui/bookdown/rstudio-ide.html
Thank you in advance for any help! I have MikTeX installed on my computer (2.9.6) and the tinytex package but Rmarkdown will not knit to a pdf (it will however for html) no matter what engine I use. I updated the packages and the other solutions seem to suggest downgrading or updating the packages so Im not sure what to do!
Output created: ttest.pdf
Error in tools::file_path_as_absolute(output_file) :
file 'ttest.pdf' does not exist
Calls: <Anonymous> -> <Anonymous>
In addition: Warning message:
In readLines(logfile) : incomplete final line found on 'ttest.log'
Execution halted
Session info
> sessionInfo()
R version 3.5.0 (2018-04-23)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United
States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] tinytex_0.5
loaded via a namespace (and not attached):
[1] compiler_3.5.0 backports_1.1.2 magrittr_1.5 rprojroot_1.3-2
htmltools_0.3.6
[6] tools_3.5.0 yaml_2.1.19 Rcpp_0.12.17 stringi_1.1.7
rmarkdown_1.10
[11] knitr_1.20 stringr_1.3.1 digest_0.6.15 evaluate_0.10.1
RMD File
---
title: "ttest"
author: "Erik Maroney"
date: "June 22, 2018"
output: pdf_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## R Markdown
This is an R Markdown document. Markdown is a simple
formatting syntax for authoring HTML, PDF, and MS Word
documents. For more details on using R Markdown see
<http://rmarkdown.rstudio.com>.
When you click the **Knit** button a document will be
generated that includes both content as well as the
output of any embedded R code chunks within the
document. You can embed an R code chunk like this:
```{r cars}
summary(cars)
```
I am struggling with changing the font of my pdf files. I don't have Helvetica on my computer so I am unable to compile .pdf (html works perfectly). I believe my Rmarkdown coding is not working but it is identical to what is suggested here. LaTeX is installed and properly working, I can compile using XeLaTeX from Lyx.
---
title: "5_jan"
author: "Matias Andina"
date: "January 5, 2017"
output:
pdf_document:
latex_engine: xelatex
sansfont: Calibri Light
---
As far as I understand, Calibri font is loaded
fonts()[grepl('Calibri',fonts())]
[1] "Calibri" "Calibri Light"
I keep geting the cannot load afm file 'Helvetica.afm' error. This is my session
sessionInfo()
R version 3.3.0 (2016-05-03)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods
[7] base
other attached packages:
[1] extrafont_0.17 knitr_1.13 dplyr_0.4.3
loaded via a namespace (and not attached):
[1] Rcpp_0.12.7 digest_0.6.9 assertthat_0.1 R6_2.1.2
[5] Rttf2pt1_1.3.4 DBI_0.4-1 magrittr_1.5 highr_0.6
[9] lazyeval_0.2.0 extrafontdb_1.0 rmarkdown_0.9.6 tools_3.3.0
[13] yaml_2.1.13 parallel_3.3.0 htmltools_0.3.5
UPDATE
The error is with R code chunks. If I knit everything but the R chunk it works
---
title: "5_jan_hplc"
author: "Matias Andina"
date: "January 5, 2017"
output:
pdf_document:
latex_engine: xelatex
mainfont: Calibri Light
---
this is my test
I can write anything here and it will render **perfectly**
```{r}
plot(mtcars)
```
processing file: test.Rmd
Quitting from lines 16-17 (test.Rmd)
Error in grDevices::pdf(NULL, width, height, ...) :
failed to initialise default PDF font
Calls: <Anonymous> ... chunk_device -> dev_new -> do.call -> <Anonymous> -> <Anonymous>
In addition: Warning messages:
1: In grDevices::pdf(NULL, width, height, ...) :
afm file 'C:\PROGRA~1\R\R-33~1.0/library/grDevices/afm/Helvetica.afm' could not be opened
2: In grDevices::pdf(NULL, width, height, ...) :
cannot load afm file 'Helvetica.afm'
Execution halted