Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
633 views
in Technique[技术] by (71.8m points)

r - Knitr wont compile PDF: "Error in tools::file_path_as_absolute(output_file)"

I have created a report in markdown and use the function render() to compile the code into a PDF. It worked fine a month ago, but when I run the code now, it gives me an error:

Latexmk: This is Latexmk, John Collins, 22 April 2016, version: 4.45. Output created: output/Medborgerskabstabeller99.pdf

Error in tools::file_path_as_absolute(output_file) : file 'output/Medborgerskabstabeller99.pdf' does not exist

The render command I use to create the PDF looks like this:

outfile <- file.path("output",paste0("Medborgerskabstabeller99"))
render(input = "Medborgerskabstabeller.Rmd",
       encoding = "UTF-8",
       output_file = paste0(outfile,".pdf"))

First of all, the "Latexmk"-message before did not appear when the code worked.

Second, I have no clue why it says that "Medborgerskabstabeller99.pdf" doesn't exist, when it says above that it just created the file.

Any suggestions on the problem will be highly appreciated!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

A better solution appears to be to use tinytex.

install.packages('tinytex')
tinytex::install_tinytex()

If you have to use MikTex and have it installed already, open the MikTex console and change the missing package setting to:

Always install missing packages on the fly

If you have not installed MikTex yet then on installation make sure to choose:

Install missing packages: Yes

When I originally installed I chose Ask me first and it would fail. I have tried both changing the settings of MikTex, as well as uninstalled it and just settled for tinytex which was a bit more lightweight for my needs.

The original thread with solution near the bottom: https://github.com/rstudio/rmarkdown/issues/1285


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...