I am trying to knit a simple R-markdown document (default document I named "exampled.Rmd"). When I try to use the Knit button it shows the following error message:
Error: object 'y' not found
Execution halted.
It is interesting, because when I run the following from the r-console,
rmarkdown::render('example.Rmd')
it generates the HTML document in the folder.
Does anybody have any idea about what is going on?
I encounter errors when running the following simple code in RMarkdown.
---
title: "debugging"
author: ""
date: "11/12/2021"
output: pdf_document
---
```{r}
library(vtable)
st(iris,out="kable")
```
I am using the latest version of tinytex and all R packages.
The error message looks like:
! Misplaced \noalign. \bottomrule ->\noalign
{\ifnum 0=`}\fi #aboverulesep =\aboverulesep \global... l.168 \bottomrule
Error: LaTeX failed to compile debug.tex. See
https://yihui.org/tinytex/r/#debugging for debugging tips. See
debug.log for more info. Execution halted
or
I was unable to find any missing LaTeX packages from the error log
manual.log. ! Misplaced \noalign. \addlinespace ->\noalign
{\ifnum 0=`}\fi #ifnextchar [{#addspace }{#addsp... l.190 \addlinespace
Error: LaTeX failed to compile manual.tex. See
https://yihui.org/tinytex/r/#debugging for debugging tips. See
manual.log for more info. In addition:
Warning messages:
1: package'vtable' was built under R version 3.6.2
2: package 'kableExtra' was built under R version 3.6.2 Execution halted
in my origin rmd file with similar code (different data frame).
I am trying RMarkdown for the first time, using the very first example in Yihui's book "R Markdown A Definitive Guide":
---
title: "Hello R Markdown"
author: "Awesome Me"
date: "2018-02-14"
output: pdf_document
---
This is a paragraph in an R Markdown document.
Below is a code chunk:
options(tinytex.verbose = TRUE)
fit = lm(dist ~ speed, data = cars)
b = coef(fit)
plot(cars)
abline(fit)
The slope of the regression is `r b[1]
I installed TinyTex using the following as per Yihui's comments here:
devtools::install_github('yihui/tinytex')
tinytex:::install_prebuilt()
Running tinytex:::is_tinytex() yields TRUE.
Clicking Knit gives me the following output. There is an error line I can't find the format file 'pdflatex.fmt'
processing file: Testpdf1.Rmd
|....................... | 33%
ordinary text without R code
|............................................... | 67%
label: unnamed-chunk-1
|......................................................................| 100%
inline R code fragments
"C:/Users/xxxxxx/Documents/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS Testpdf1.utf8.md --to latex --from markdown+autolink_bare_uris+tex_math_single_backslash --output Testpdf1.tex --self-contained --highlight-style tango --pdf-engine pdflatex --variable graphics --lua-filter "C:/Users/xxxxxx/Documents/R/R-3.6.1/library/rmarkdown/rmd/lua/pagebreak.lua" --lua-filter "C:/Users/xxxxxx/Documents/R/R-3.6.1/library/rmarkdown/rmd/lua/latex-div.lua" --variable "geometry:margin=1in"
output file: Testpdf1.knit.md
This is pdfTeX, Version 3.14159265-2.6-1.40.20 (TeX Live 2019/W32TeX) (preloaded format=pdflatex)
restricted \write18 enabled.
I can't find the format file `pdflatex.fmt'!
kpathsea: Running mktexfmt pdflatex.fmt
The command name is C:\Users\xxxxxx\AppData\Roaming\TinyTeX\bin\win32\mktexfmt
I was unable to find any missing LaTeX packages from the error log Testpdf1.log.
! kpathsea: Running mktexfmt pdflatex.fmt
! The command name is C:\Users\xxxxxx\AppData\Roaming\TinyTeX\bin\win32\mktexfmt
Error: LaTeX failed to compile Testpdf1.tex. See https://yihui.org/tinytex/r/#debugging for debugging
tips. See Testpdf1.log for more info.
Execution halted
I am trying to compile a pdf file. I am running Windows behind my company firewall. Searching for that file 'pdflatex.fmt' on my computer yields nothing. I have been searching for solution on the net for a while but can't relate to the problem. Does anyone know how I go about solving this?
Update on 2020/05/14: this is unlikely to be the solution to the recent breakage in TeX Live. If anyone reached here through searches, you have to wait until the breakage is resolved.
It may be the same issue as this one, so please try
tinytex::tlmgr_install(c('texlive-scripts', 'dehyph-exptl'))
I am trying to compile an rmarkdown document that includes a geographic plot into a PDF file. Here is a MWE:
---
title: "Problems with maps in tikz"
output: pdf_document
---
```{r setup, include=FALSE}
library(ggplot2)
library(sf)
```
## sf:png
Builds find when `nctikz` chunk is excluded.
```{r nc}
nc <- sf::st_read(system.file("shape/nc.shp", package = "sf"), quiet = TRUE)
ggplot(nc) +
geom_sf(aes(fill = AREA))
```
## sf:tikz
This graphic fails to build.
```{r nctikz, dev = 'tikz'}
ggplot(nc) +
geom_sf(aes(fill = AREA))
```
I am compiling this document using the "Knit" button in RStudio. I'm going to discuss each of the errors / warnings I get when I compile the document in case one leads to the others.
tinytex
Every time I try to run a chunk that includes dev = 'tikz', tinytex will try to reinstall the pgf TeX package, then discover it's already there, then give up trying to link it. I'm able to build document with non-geographic tikz outputs, however, so I've mostly just accepted this fact.
tlmgr search --file --global '/tikzlibrarytopaths.code.tex'
Trying to automatically install missing LaTeX packages...
tlmgr install pgf
tlmgr: package repository http://mirror.utexas.edu/ctan/systems/texlive/tlnet (not verified: gpg unavailable)
tlmgr install: package already present: pgf
tlmgr path add
add_link_dir_dir: /usr/local/share/info/dir exists; not making symlink.
Invalid characters
Tikz (in knitr) seems unable to handle the degree symbol as part of a tex file. As a note, the nctikz-1.tex object can be built by pdflatex without issue.
! Package inputenc Error: Invalid UTF-8 byte "B0.
Quitting from lines 24-27 (test.Rmd)
Error: Failed to compile test_files/figure-latex/nctikz-1.tex. See https://yihui.name/tinytex/r/#debugging for debugging tips. See nctikz-1.log for more info.
Underscore in filepath
I can get around the invalid characters error by suppressing the axis titles theme(axis.text = element_blank()) on my plot, but this then introduces another error dealing with bringing in a file.
! Missing $ inserted.
<inserted text>
$
l.3975 ...72.27pt,interpolate=true]{nctikz-1_ras1}
};
Quitting from lines 24-27 (test.Rmd)
The full line that generates this error is
\node[inner sep=0pt,outer sep=0pt,anchor=south west,rotate= 0.00] at (423.16, 120.24) {
\pgfimage[width= 14.45pt,height= 72.27pt,interpolate=true]{nctikz-1_ras1}};
The image it's trying to reference is barely an image (I think it's for the legend).
Environment
I am building this document on MacOS with a whole pile of libraries. In an effort to isolate the issue, I also attempted to build the document on Rstudio.cloud (Ubuntu) in a brand new project. In this environment, only the issue with the math environment / underscore occurs.
! Missing $ inserted.
<inserted text>
$
l.4049 ...72.27pt,interpolate=true]{nctikz-1_ras1}
};
Quitting from lines 26-28 (test.Rmd)
Error: Failed to compile test_files/figure-latex/nctikz-1.tex. See https://yihui.name/tinytex/r/#debugging for debugging tips. See nctikz-1.log for more info.
Not a full answer, but I would like to document my current state:
It makes sense to enable debugging by adding
```{r, include=FALSE}
options(tinytex.verbose = TRUE)
```
to the Rmd file as suggested.
The pgf issue is sort of a red herring. With debugging we see that it happens after some other error occurs (illegal character or underscore in file path). The corresponding regular expression was recently introduced and should probably be extended to check for actual error messages from Tikz/pgf.
I can reproduce the illegal character on Debian Linux. Somehow ° is written as 0xB0, i.e. Latin-1 encoded instead of UTF-8. I am not sure why/where this is happening. BTW, I can process the resulting tex file directly with pdflatex only from RStudio, since that re-encodes the 0xB0 as a question mark. If I use pdflatex via Emacs or directly on the command line, I get the same error message.
Removing the degree symbol from the output via
```{r nctikz, dev = 'tikz'}
ggplot(nc) +
theme(axis.text = element_blank()) +
geom_sf(aes(fill = AREA))
```
I can reproduce the "underscore in file path" issue. With debugging turned on, one sees that the issue is again somewhere else:
Package pgf Warning: File "nctikz-1_ras1" not found when defining image "pgflas
timage". Tried all extensions in ".pdf:.jpg:.jpeg:.png:" on input line 3975.
! Missing $ inserted.
<inserted text>
$
l.3975 ...72.27pt,interpolate=true]{nctikz-1_ras1}
};
! ==> Fatal error occurred, no output PDF file produced!
The file nctikz-1_ras1.png that is present in the same directory as nctikz-1.tex is not found. One can reproduce this issue directly using
tinytex::latexmk("<path>/nctikz-1.tex", install_packages = FALSE, clean = FALSE)
However, if one changes to the directory first, no such error occurs:
setwd("<path>")
tinytex::latexmk("./nctikz-1.tex", install_packages = FALSE, clean = FALSE)
I'm running a ShinyApp on our own RShiny-Server. I have a DESCRIPTION file in order to use the Showcase mode. Until now everything went smooth, but today I saw the following error in the log file.
Can anyone help on the following error in my Shiny log file?
ERROR system error 71 (Protocol error) [description=Package field not found in /home/[…]/DESCRIPTION]
OCCURED AT: read#core/r-util/RPackageInfo.cpp#85
LOGGED FROM: isPackageDirectory#core/r_util/RPackageInfo.cpp#121
Thanks for any hints.