I'm having problems knitting an .rmd file to a .html (and pdf for that matter) file using rmarkdown. The report that I'm trying to knit in the following example is just the example report you get when starting a new rmakrdown document.
This is the error message I get:
==> rmarkdown::render('C:/Users/***/Documents/test/test.Rmd', encoding = 'UTF-8');
processing file: test.Rmd
|.......... | 14%
ordinary text without R code
|.................... | 29%
label: setup (with options)
List of 1
$ include: logi FALSE
|.............................. | 43%
ordinary text without R code
|........................................ | 57%
label: cars
|.................................................. | 71%
ordinary text without R code
|............................................................ | 86%
label: pressure (with options)
List of 1
$ echo: logi FALSE
|......................................................................| 100%
ordinary text without R code
output file: test.knit.md
"C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS test.utf8.md --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash --output test.html --email-obfuscation none --self-contained --standalone --section-divs --template "\\storage-***.se\home$\****\My Documents\R\win-library\4.0\rmarkdown\rmd\h\default.html" --no-highlight --variable highlightjs=1 --variable "theme:bootstrap" --include-in-header "C:\Users\*****\AppData\Local\Temp\Rtmpc1mrLs\rmarkdown-str511010115ff7.html" --mathjax --variable "mathjax-url:https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" --lua-filter "\\storage-****.se/home$/****/My Documents/R/win-library/4.0/rmarkdown/rmd/lua/pagebreak.lua" --lua-filter "\\storage-***-se/home$/*****/My Documents/R/win-library/4.0/rmarkdown/rmd/lua/latex-div.lua"
pandoc.exe: \\: openBinaryFile: does not exist (No such file or directory)
Error: pandoc document conversion failed with error 1
Execution halted
Pandoc tries to reach a file saved on my computer but for some reason can't find it. This is my work computer where everything is saved locally and then uploaded to a server. I have talked with IT at my office and they don't know why it wont work.
I have managed to get a rmarkdown report before when I moved EVERYTHING (r project, packages and the files where I do my analysis) to a map that is not uploaded to the backup server.
However, this is not a safe way since there is no backup, obviously. I've tried to just have the r-project locally for the knitting but it doesn't work either.
Why can't pandoc find this binary file and is there a way I can get it to work without having to risk the safety of my work? If not, is there another way of creating similar files without pandoc?
I have seen similar questions but nothing that could give me any answers. Or give the people at the IT department any clues.
Thanks!
Johanna
Here is the session information:
> sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17134)
Matrix products: default
locale:
[1] LC_COLLATE=Swedish_Sweden.1252 LC_CTYPE=Swedish_Sweden.1252
[3] LC_MONETARY=Swedish_Sweden.1252 LC_NUMERIC=C
[5] LC_TIME=Swedish_Sweden.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_4.0.2 htmltools_0.5.0 tools_4.0.2 yaml_2.2.1 rmarkdown_2.3
[6] knitr_1.29 xfun_0.16 digest_0.6.25 rlang_0.4.7 evaluate_0.14
Versions:
> version
_
platform x86_64-w64-mingw32
arch x86_64
os mingw32
system x86_64, mingw32
status
major 4
minor 0.2
year 2020
month 06
day 22
svn rev 78730
language R
version.string R version 4.0.2 (2020-06-22)
nickname Taking Off Again
> pandoc_version()
[1] ‘2.7.2’
> pandoc_available()
[1] TRUE
I have solved the problem!
The actual problem was the path of the rmarkdown package. It was on my //storage... path. What I finally had to do was to go into system settings and add an environmental variable for R_LIBS_USER to my H:/ path. Now when pandoc is looking for the rmarkdown details it can find the path.
Using this link as research. try using the RELATIVE path for your file. in this one you are using the absolute path C:/Users/... and this temporarily changes R's working directory.
Related
While working in a conda environment, I have been observing an unexpected behavior with R>=4.1.3. Namely, in terminal I can launch R and load GDAL-based libraries
R version 4.1.3 (2022-03-10) -- "One Push-Up"
Copyright (C) 2022 The R Foundation for Statistical Computing
Platform: x86_64-conda-linux-gnu (64-bit)
... STANDARD R MESSAGE ...
> library(sf)
Linking to GEOS 3.11.1, GDAL 3.6.2, PROJ 9.1.0; sf_use_s2() is TRUE
but in RStudio I get the error below
R version 4.1.3 (2022-03-10) -- "One Push-Up"
Copyright (C) 2022 The R Foundation for Statistical Computing
Platform: x86_64-conda-linux-gnu (64-bit)
... STANDARD R MESSAGE ...
> library(sf)
Error: package or namespace load failed for ‘sf’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/home/ivan/miniconda3/envs/r41_dev/lib/R/library/sf/libs/sf.so':
/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.30' not found (required by /home/ivan/miniconda3/envs/r41_dev/lib/R/library/sf/libs/../../../../libgdal.so.32)
Even though the behavior in terminal suggested that the package libstdc++ was installed, I have reinstalled it from the Gnome repo. The package is definitely installed on my machine.
apt list --installed | grep libstdc++
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
libstdc++-8-dev/focal,now 8.4.0-3ubuntu2 amd64 [installed,automatic]
libstdc++-9-dev/focal-updates,focal-security,focal-security,now 9.4.0-1ubuntu1~20.04.1 amd64 [installed,automatic]
libstdc++6/focal,now 11.1.0-1ubuntu1~20.04 amd64 [installed]
libstdc++6/focal,now 11.1.0-1ubuntu1~20.04 i386 [installed,automatic]
The Rstudio version is
RStudio 2022.07.2+576 "Spotted Wakerobin" Release (e7373ef832b49b2a9b88162cfe7eac5f22c40b34, 2022-09-06) for Ubuntu Bionic
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) QtWebEngine/5.12.8 Chrome/69.0.3497.128 Safari/537.36
And here the session info
> sessionInfo()
R version 4.1.3 (2022-03-10)
Platform: x86_64-conda-linux-gnu (64-bit)
Running under: Ubuntu 20.04.5 LTS
Matrix products: default
BLAS/LAPACK: /home/ivan/miniconda3/envs/r41_dev/lib/libopenblasp-r0.3.21.so
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=de_DE.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=de_DE.UTF-8 LC_MESSAGES=en_US.UTF-8 LC_PAPER=de_DE.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=de_DE.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_4.1.3 magrittr_2.0.3 class_7.3-21 DBI_1.1.3 tools_4.1.3 units_0.8-1
[7] proxy_0.4-27 Rcpp_1.0.10 KernSmooth_2.23-20 grid_4.1.3 e1071_1.7-13 classInt_0.4-8
I have been using conda environments with RStudio for a while and I have come across multiple challenges but I don't seem capable to come around this one.
Can anyone help me understand how come RStudio cannot access this package while R can access it from terminal?
As as side note, the problem does not occur with R=4.0.5 and, to the best of my knowledge, did not occur with R=4.1 either. I certainly have update apt multiple times, but I cannot recall any major update to my system.
EDIT TO ADDRESS THE POINTS RAISED BY #merv IN COMMENTS
I have created several environments with different R versions in the attempt to frame and solve this problem, without success.
I've now followed these steps:
check conda version with conda -V, returns conda 22.11.1
create a fresh environment with conda create -n r41_test -c conda-forge r-base=4.1.3 r-sf -y
activate the environment with conda activate r41_test
1 save the conda list output to file and share it through this link
launch R from terminal
load the sf library with library(sf), the library loads without issues
close R with q() and type n to avoid workspace image to be saved
launch RStudio by typing rstudio (from the activated environment)
load library sf with library(sf) from the R console in RStudio, the library fails loading with the same error reported above.
While running this test, I have noticed something I had not noticed before: when the conda environment at step 2, the following message was printed, but the environment was successfully create. I could also activate it, launch R from terminal, and load the library despite the SafetyError.
Downloading and Extracting Packages
Preparing transaction: done
Verifying transaction: |
SafetyError: The package for r-base located at /home/ivan/miniconda3/pkgs/r-base-4.1.3-h2f963a2_5
appears to be corrupted. The path 'lib/R/doc/html/packages.html'
has an incorrect size.
reported size: 3061 bytes
actual size: 55120 bytes
done
Previous my post, I have tried this procedure also on another laptop running Ubuntu 20.04. I barely use that machine so it may serve as an 'independent control'. I am not sure whether the SafetyError was thrown also there, but RStudio failed to load the package also on that machine.
I'm getting an error building R for Data Science in ePub format
> render_book("index.rmd", epub_book())
output file: strings.knit.md
Error: Functions that produce HTML output found in document targeting epub3 output.
Please change the output type of this document to HTML. Alternatively, you can allow
HTML output in non-HTML formats by adding this option to the YAML front-matter of
your rmarkdown file:
always_allow_html: true
Note however that the HTML output will not be visible in non-HTML formats.
Execution halted
Error in Rscript_render(f, render_args, render_meta, add1, add2) :
Failed to compile strings.Rmd
sessionInfo()
R version 3.5.2 (2018-12-20)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Debian GNU/Linux 10 (buster)
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.8.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.8.0
attached base packages:
[1] stats graphics grDevices utils datasets methods base
Is there something I can do to allow compilation to ePub that will keep all content intact?
For my bookdown::gitbook project I deleted my _output.yml and _bookdon.yml files from the book directory and specified the sharing settings, documentation class etc in the Index.Rmd file.This solved it for my HTML output but I'm not sure whether the same applies for ePub formats.
I am having similar problems, and (for me) narrowed it down to using kable_styling (epub format with kable_styling fails)
No solution yet though... :-<
P.
I'm compiling a pdf using child .Rmd's. The example_child.Rmd calls an image using knitr::include_graphics() and compiles fine on its own, but trying to compile example_main.Rmd produces the following error.
TeX Live 2019 is frozen forever and will no
longer be updated. This happens in preparation for a new release.
If you're interested in helping to pretest the new release (when
pretests are available), please read https://tug.org/texlive/pretest.html.
Otherwise, just wait, and the new release will be ready in due time.
! LaTeX Error: File `images/example_image' not found.
Error: LaTeX failed to compile example_main.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See example_main.log for more info.
Execution halted
example_main.Rmd compiles fine when only calling child documents that don't call images (it calls data from sub-folders just fine). Any help would be appreciated! All the relevant info about my session and files is below:
My working directory is "/Users/example_project"
The example_main.Rmd (file path "/Users/example_project/folder_1/example_main.Rmd") YAML and code-chunk are as follows:
---
output:
pdf_document:
latex_engine: xelatex
---
```{r child = './folder_2/example_child.Rmd'}
```
The example_child.Rmd (file path "/Users/example_project/folder_1/folder_2/example_child.Rmd") YAML and code chunk are as follows:
---
output: pdf_document
---
```{r example, echo = FALSE, out.width='80%', out.height='50%'}
knitr::include_graphics("./images/example_image.png")
```
The full image file path is "/Users/example_project/folder_1/folder_2/images/example_image.png".
My session info is as follows:
R version 3.6.3 (2020-02-29)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Mojave 10.14.6, RStudio 1.2.5033
Locale: en_US.UTF-8 / en_US.UTF-8 / en_US.UTF-8 / C / en_US.UTF-8 / en_US.UTF-8
Package version:
base64enc_0.1.3 digest_0.6.25 evaluate_0.14 glue_1.4.0 graphics_3.6.3 grDevices_3.6.3 highr_0.8
htmltools_0.4.0 jsonlite_1.6.1 knitr_1.28.2 magrittr_1.5 markdown_1.1 methods_3.6.3 mime_0.9
Rcpp_1.0.4 rlang_0.4.5 rmarkdown_2.1 stats_3.6.3 stringi_1.4.6 stringr_1.4.0 tinytex_0.21.1
tools_3.6.3 utils_3.6.3 xfun_0.12 yaml_2.2.1
Pandoc version: 2.3.1
You can reconstruct the path to the image using the working directory of the child document (in example_child.Rmd)
---
output: pdf_document
---
```{r example, echo = FALSE, out.width='80%', out.height='50%'}
knitr::include_graphics(paste0(getwd(), "/images/example_image.png"))
```
It seem that this is an issue with 'grandchild' documents similar to that described here and here
I want to change the documentclass to 'scrbook'. In the index.Rmd file of minimal bookdown example I changed the line documentclass: book to documentclass: scrbook but this didn't work. I got the following error message:
Latexmk: applying rule 'pdflatex'...
Latexmk: This is Latexmk, John Collins, 19 Jan. 2017, version: 4.52c.
Rule 'pdflatex': File changes, etc:
Non-existent destination files:
'test-bookdown.pdf'
------------
Run number 1 of rule 'pdflatex'
------------
------------
Running '/Library/TeX/texbin/xelatex -halt-on-error -interaction=batchmode -recorder "test-bookdown.tex"'
------------
This is XeTeX, Version 3.14159265-2.6-0.99998 (TeX Live 2017) (preloaded format=xelatex)
restricted \write18 enabled.
entering extended mode
=== TeX engine is 'XeTeX'
Latexmk: Errors, so I did not complete making targets
Latexmk: Log file says no output from latex
Latexmk: For rule 'pdflatex', no output was made
Collected error summary (may duplicate other messages):
pdflatex: Command for 'pdflatex' gave return code 1
Refer to 'test-bookdown.log' for details
Latexmk: Use the -f option to force complete processing,
unless error was exceeding maximum runs of latex/pdflatex.
! LaTeX Error: Command \subtitle already defined.
Or name \end... illegal, see p.192 of the manual.
Error: Failed to compile test-bookdown.tex. See test-bookdown.log for more info.
Please delete test-bookdown.Rmd after you finish debugging the error.
Execution halted
Exited with status 1.
Is there a way to change to other document classes besides those supported by pandoc (article, report, book, memoir)?
I used for the compilation the command rmarkdown::render_site(output_format = 'bookdown::pdf_book', encoding = 'UTF-8') as provided by the Build Book tab.
R version 3.4.2 (2017-09-28)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Sierra 10.12.6
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_3.4.2 backports_1.1.1 bookdown_0.5.4 magrittr_1.5 rprojroot_1.2
[6] htmltools_0.3.6 tools_3.4.2 yaml_2.1.14 Rcpp_0.12.13 stringi_1.1.5
[11] rmarkdown_1.6.0.9004 knitr_1.17 stringr_1.2.0 digest_0.6.12 evaluate_0.10.1
> rmarkdown::pandoc_version()
[1] ‘1.19.2.1’
> system('pdflatex --version')
pdfTeX 3.14159265-2.6-1.40.18 (TeX Live 2017)
kpathsea version 6.2.3
Copyright 2017 Han The Thanh (pdfTeX) et al.
There is NO warranty. Redistribution of this software is
covered by the terms of both the pdfTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the pdfTeX source.
Primary author of pdfTeX: Han The Thanh (pdfTeX) et al.
Compiled with libpng 1.6.29; using libpng 1.6.29
Compiled with zlib 1.2.11; using zlib 1.2.11
Compiled with xpdf version 3.04
I used scrbook as an example in the bookdown book in Section 4.2. Had you searched for scrbook using the search button, you would have discovered it. I'm not going to copy the full example here, but the key is template: null, and that is because rmarkdown's default Pandoc LaTeX template does not work with scrbook, and Pandoc's LaTeX template does. You can certainly provide your own Pandoc LaTeX template.
I have this basic R markdown file:
---
title: 'test'
output:
html_document
---
![myimage](test.png)
The file test.png can be found in the project folder. If I compile the document the first time all is good:
|.................................................................| 100%
ordinary text without R code
/Applications/RStudio.app/Contents/MacOS/pandoc/pandoc +RTS -K512m -RTS /Users/nf/test/test_file.utf8.md --to html --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output test_file.html --smart --email-obfuscation none --self-contained --standalone --section-divs --template /Library/Frameworks/R.framework/Versions/3.2/Resources/library/rmarkdown/rmd/h/default.html --variable 'theme:bootstrap' --include-in-header /var/folders/x0/87l48swx73lg569_81cctqt00000gp/T//RtmpYYJgwp/rmarkdown-stree426f43954e.html --mathjax --variable 'mathjax-url:https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' --no-highlight --variable highlightjs=/Library/Frameworks/R.framework/Versions/3.2/Resources/library/rmarkdown/rmd/h/highlight
processing file: test_file.Rmd
output file: /Users/nf/test/test_file.knit.md
Output created: test_file.html
But if I compile it the second time (without changing anything) I get this error:
|.................................................................| 100%
ordinary text without R code
processing file: test_file.Rmd
output file: /Users/nf/test/test_file.knit.md
/Applications/RStudio.app/Contents/MacOS/pandoc/pandoc +RTS -K512m -RTS /Users/nf/test/test_file.utf8.md --to html --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output test_file.html --smart --email-obfuscation none --self-contained --standalone --section-divs --template /Library/Frameworks/R.framework/Versions/3.2/Resources/library/rmarkdown/rmd/h/default.html --variable 'theme:bootstrap' --include-in-header /var/folders/x0/87l48swx73lg569_81cctqt00000gp/T//RtmprFBDzb/rmarkdown-streef56b8e7e99.html --mathjax --variable 'mathjax-url:https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' --no-highlight --variable highlightjs=/Library/Frameworks/R.framework/Versions/3.2/Resources/library/rmarkdown/rmd/h/highlight
pandoc: Could not fetch test.png
test.png: openBinaryFile: does not exist (No such file or directory)
Error: pandoc document conversion failed with error 67
Execution halted
If I look into my project folder the image test.png is gone. In the process of the first compilation of the document the image get's deleted. I can reproduce it every time. And then of course it is missing for the second compilation. This also happens with .RData files I load inside R chunks. I even tried to keep the files in a separate folder and copy them every time inside my project folder I compile my document (with the command file.copy()). But then the files in the outside folder disappear as well. It seems that every file mentioned in the markdown document gets deleted or moved somewhere else.
What I found out is that this happens only if the name of the markdown file contains spaces like test file.Rmd. Html pages produced from this file are formated test_file.html so I guess some transformation to a filename without spaces takes place.
I think this is a bug I should report on some bug tracker, but since I don't know whether this is about rmarkdown, knitr, pandoc, RStudio or something else I post it here.
My session info:
R version 3.2.2 (2015-08-14)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.11.2 (El Capitan)
locale:
[1] de_DE.UTF-8/de_DE.UTF-8/de_DE.UTF-8/C/de_DE.UTF-8/de_DE.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] knitr_1.11
loaded via a namespace (and not attached):
[1] tools_3.2.2
Updating to rmarkdown_0.9.2 fixed the problem according to this issue: https://github.com/rstudio/rmarkdown/issues/580