R markdown "magic number" error? [duplicate] - r

This question already has an answer here:
Rmarkdown: pandoc document conversion failed with error 43 because of large number
(1 answer)
Closed 6 years ago.
I'm trying to knit following Rmardown:
---
title: "Title"
author: "Author"
date: '20 nov 2016 г '
output:
pdf_document:
latex_engine: xelatex
---
## Next inline code produced error: `r 98809`
Error:
processing file: 111.Rmd
output file: 111.knit.md
! Missing $ inserted.
<inserted text>
$
l.91 ...e code produced error: 9.880910\^{}\{4\}}}
pandoc.exe: Error producing PDF
Ошибка: pandoc document conversion failed with error 43
If I edit the number and delete last "9" to looks likes this r 9880 all going to be fine...
Is this a bug?
I'm testing on fresh R:
> sessionInfo()
R version 3.3.2 (2016-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
locale:
[1] LC_COLLATE=Russian_Russia.1251 LC_CTYPE=Russian_Russia.1251 LC_MONETARY=Russian_Russia.1251 LC_NUMERIC=C LC_TIME=Russian_Russia.1251
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] magrittr_1.5 assertthat_0.1 htmltools_0.3.5 tools_3.3.2 yaml_2.1.13 tibble_1.2 Rcpp_0.12.7 stringi_1.1.2 rmarkdown_1.1 stringr_1.1.0 digest_0.6.10
[12] evaluate_0.10
>

Try modify the last line of your file:
## Next inline code produced error: `r format(98809)`

Related

R Markdown won't knit; Error in parse attempt to use zero-length variable name

I'm trying to prepare an Rmarkdown file for a course. But for some reason (perhaps a very, very dumb reason) I can't seem to knit anything. Here is a very simple example of an Rmarkdown script:
---
title: "big data"
author: "CAM"
date: "21 March 2020"
output:
html_document: default
---
```{r,chunk1,eval=TRUE,echo=TRUE,include=TRUE}
seq(1,10,by=1)
```
This throws the error:
Error in parse(text = x, keep.source = TRUE) :
attempt to use zero-length variable name
Calls: <Anonymous> -> <Anonymous> -> getParseData -> parse
Execution halted
The code itself executes in the chunk, but it won't knit.
Here is my session info. (I just moved to catalina on mac, maybe there's a problem here).
R version 3.6.3 (2020-02-29)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Catalina 10.15.3
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.6/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
[6] methods base
other attached packages:
[1] knitr_1.28 rmarkdown_2.1
loaded via a namespace (and not attached):
[1] compiler_3.6.3 htmltools_0.4.0 tools_3.6.3
[4] yaml_2.2.1 Rcpp_1.0.3 xfun_0.12
[7] digest_0.6.25 rlang_0.4.5 evaluate_0.14
Found the answer. It's has to be saved as a .Rmd file, not an .R file. This is the case even if you selected your script as a Rmarkdown file within RStudio.

Cross-referencing of sections in bookdown::word_document2 not working [duplicate]

This question already has answers here:
Bookdown: Chapter/Section cross referencing not working (gitbook)
(2 answers)
Closed 3 years ago.
Title says it all. See below for a minimal (non-)working example.
---
title: "Untitled"
author: "Anonymous"
date: "09/01/2020"
output: bookdown::word_document2
---
# First Section {#sec1}
Etc.
# Second Section
See section \#ref(sec1).
When I knit the above, I get the following warning:
Output created: mre.docx
Warning message:
The label(s) sec1 not found
The reference in the output is replaced with two question marks (??). When I replace the output option in the YAML header with pdf_document2, there is no error. My template.docx has section numbering enabled for all heading styles and the sections are numbered correctly (just not the references).
> sessionInfo()
R version 3.6.2 (2019-12-12)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Arch Linux
Matrix products: default
BLAS: /usr/lib/libblas.so.3.9.0
LAPACK: /usr/lib/liblapack.so.3.9.0
locale:
[1] LC_CTYPE=en_GB.UTF-8 LC_NUMERIC=C LC_TIME=en_GB.UTF-8 LC_COLLATE=en_GB.UTF-8 LC_MONETARY=en_GB.UTF-8 LC_MESSAGES=en_GB.UTF-8 LC_PAPER=en_GB.UTF-8
[8] LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=en_GB.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_3.6.2 Matrix_1.2-18 bookdown_0.16 htmltools_0.4.0 tools_3.6.2 yaml_2.2.0 reticulate_1.13 Rcpp_1.0.3 rmarkdown_1.17 grid_3.6.2 knitr_1.26 jsonlite_1.6
[13] digest_0.6.22 xfun_0.11 rlang_0.4.1 lattice_0.20-38 evaluate_0.14
> pandoc --version
pandoc 2.8
Compiled with pandoc-types 1.20, texmath 0.12, skylighting 0.8.3
I have been struggling with the same issue and I found a workaround
This is a known issue that the Rstudio group is working on.
https://github.com/rstudio/bookdown/issues/787
I was able to work around this problem by using the version of pandoc that is installed with Rstudio (currently 2.7.2). In windows I did this by removing pandoc from the PATH and then restarting my Rstudio session.

Error creating notebook: no lines available in input

When trying to Preview a simple notebook in RStudio, I am getting the following error in the top of the source pane and no nb.html file is created:
"Error creating notebook: no lines available in input"
Screenshot:
> sessionInfo(package = NULL)
R version 3.3.3 (2017-03-06)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
locale:
[1] LC_COLLATE=German_Austria.1252 LC_CTYPE=German_Austria.1252 LC_MONETARY=German_Austria.1252 LC_NUMERIC=C LC_TIME=German_Austria.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] backports_1.0.5 magrittr_1.5 rprojroot_1.2 htmltools_0.3.6 tools_3.3.3 base64enc_0.1-3 yaml_2.1.14 Rcpp_0.12.12 stringi_1.1.3 rmarkdown_1.8 knitr_1.17
[12] stringr_1.2.0 digest_0.6.12 evaluate_0.10
> RStudio.Version()
$mode
[1] "desktop"
$version
[1] ‘1.0.153’
I wasn't able to replicate the exact error but you could try writing the output html notebook in same line.
---
title: "R Notebook"
output: html_notebook: default
html_document: default
---
I fixed this by opening a new Notebook, copying the contents of my original, error-ing Notebook there, and then overwriting the original Notebook. The error presented, for me, after I moved a folder containing all the files associated with this project to a new location.

R pander package: Unable to run CrossTable example in Rmd document

I am unable to compile a Rmd as pdf with the CrossTable example from the "Using pander with knitr" vignette.
Here is my code
---
title: "Pander CrossTable test"
author: "Christiaan Pauw"
date: "08 March 2016"
output: pdf_document
---
```{r }
library(pander)
library(descr, quietly = TRUE)
pander(CrossTable(mtcars$gear, mtcars$cyl))
```
The error message reads:
output file: Untitled.knit.md
! LaTeX Error: There's no line here to end.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.159 ~\\15\\\\
pandoc: Error producing PDF from TeX source
Error: pandoc document conversion failed with error 43
Execution halted
Here is my session info
> sessionInfo()
R version 3.2.3 (2015-12-10)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.10.5 (Yosemite)
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
other attached packages:
[1] descr_1.1.2 pander_0.6.0 ggplot2_2.0.0 reshape2_1.4.1 stargazer_5.2 raster_2.5-2
[7] Matrix_1.2-3 sp_1.2-1
loaded via a namespace (and not attached):
[1] Rcpp_0.12.3 knitr_1.12.3 magrittr_1.5 munsell_0.4.2 colorspace_1.2-6
[6] xtable_1.8-0 lattice_0.20-33 stringr_1.0.0 plyr_1.8.3 tools_3.2.3
[11] grid_3.2.3 gtable_0.1.2 htmltools_0.3 yaml_2.1.13 digest_0.6.9
[16] rmarkdown_0.9.5.1 stringi_1.0-1 scales_0.3.0
For the record: The problem seemed to solve itself. When I returned to this problem after a few updates everything worked
It works for R version 3.3.0 with Rstudio Version 0.99.902. The pandoc version is 1.15.2

Knitr does not render googleVis

I have a trouble with Rsutdio and knitr in Windows 7 for rendering a simple gvisTable. Here is my code
```{r results='asis'}
require(googleVis)
op <- options(gvis.plot.tag="chart")
data(iris)
t = gvisTable(data = iris)
print(t)
```
and here is my error :
pandoc.exe: Failed to retrieve https://www.google.com/jsapi?callback=displayChartTableID14c4345d7f3
FailedConnectionException2 "www.google.com" 443 True connect: failed (Connection timed out (WSAETIMEDOUT))
Erreur : pandoc document conversion failed with error 61
My Rstudio version is : 0.98.1091
And my SessionInfo is :
R version 3.1.2 (2014-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=French_France.1252 LC_CTYPE=French_France.1252 LC_MONETARY=French_France.1252
[4] LC_NUMERIC=C LC_TIME=French_France.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] plotrix_3.5-10 data.table_1.9.4 googleVis_0.5.6 knitr_1.8
loaded via a namespace (and not attached):
[1] chron_2.3-45 digest_0.6.4 evaluate_0.5.5 formatR_1.0 htmltools_0.2.6 plyr_1.8.1 Rcpp_0.11.3
[8] reshape2_1.4 RJSONIO_1.3-0 rmarkdown_0.3.11 stringr_0.6.2 tools_3.1.2 yaml_2.1.13
or this code works perfectly fine :
```{r results='asis'}
require(knitr)
data(iris)
kable(iris)
```
Do you have any idea of the problem with googleVis in this context ? Thanks in advance for any help.
Pandoc is trying to download the googleVis chart so that it can embed a static/offline copy in your document. You can work around the problem by telling Pandoc not to create a standalone document (i.e. don't do the resource embedding that's causing the problem)--add this to the top of your document, or just the text between --- if you already have a YAML header:
---
output:
html_document:
self_contained: no
---
Pandoc shouldn't have a problem fetching resources over https. If you have time to repro the problem outside the rmarkdown workflow (i.e. on a vanilla Markdown -> HTML conversion) and find that it's still an issue, please file an issue for Pandoc: https://github.com/jgm/pandoc/issues.

Resources