I can't knit my documents into PDF in RStudio - r

I have to use RStudio to knit a report in PDF but when I try to knit the document with the packages required in a chunk in Rmarkdown it shows me this error:
tlmgr search --file --global '/multirow.sty'
tlmgr: Remote repository is newer than local (2018 < 2019)
Cross release updates are only supported with
update-tlmgr-latest(.sh/.exe) --update
Please see https://tug.org/texlive/upgrade.html for details.
! LaTeX Error: File `multirow.sty' not found.
! Emergency stop.
<read *>
Errore: Failed to compile questionario_sulla_responsabilita_222222.tex. See https://yihui.name/tinytex/r/#debugging for debugging tips. See questionario_sulla_responsabilita_222222.log for more info.
Inoltre: Warning message:
In system2("tlmgr", args, ...) :
running command ''tlmgr' search --file --global '/multirow.sty'' had status 1
Execution interrupted
how can I fix this? I am using a MacBook Pro
I tried to updated everything I can and I've tried to install everything from the beginning but it jeeps showing me the same error message

To wrap the comments to the question up and following the solution at Yihui Xie's page - see also here for a discussion.
In short ...
tinytex::reinstall_tinytex()
... should do the trick.
Explanation: It seems that {tinytex}/Texlive is using a rolling package repository that moves to a new version each year while the local installment does not. The reinstallation does move the local installment forward.
An alternative solution: There seems to be an alternative solution that involves making the TexLive package repo un-rolling - i.e. using a fixed version - which might help: link

Related

R MarkDown Error: pandoc version 1.12.3 or higher is required and was not found

I'm using R Studios Cloud but I am suddenly experiencing difficulty knitting my markdown in any format (html, pdf & word).
This is the error I'm thrown when I press the knit button:
pandoc version 1.12.3 or higher is required and was not found (see the help page ?
rmarkdown::pandoc_available).
Execution halted
I then check if pandoc is installed via pandoc_available():
> pandoc_available()
[1] FALSE
False, so I try to install pandoc again? (I do not recall uninstalling it)
> installr::install.pandoc()
sh: 1: ifconfig: not found
Error in system("ifconfig", intern = TRUE) : error in running command
However, again I get another error for ifconfig: not found.
I am new to learning R and programming as a whole. I'm quite stumped. I have checked recent threads including popular solutions (linked below) to no avail.
I have also tried opening a new markdown file but still could not get knit to work.
I'd appreciate any help on this one.
popular solution to resolve pandoc version 1.12.3 error
Found the solution.
Relaunch your project by clicking on the 3 dots in the upper right corner.
See thread here.
Seems to be a common error happening to a lot of r studio cloud users in the past 24 hours.

Debugging problem when knitting from r markdown to pdf

I've downloaded miktex, tinytex and ghostscript and tried changing the path since the problem seems to be in the path. So far nothing has helped me and I would appreciate some help:
This is my error message:
Error: LaTeX failed to compile Uebungsblatt1_MAT183.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See Uebungsblatt1_MAT183.log for more info.
In addition: Warning message:
In has_crop_tools() :
Tool(s) not installed or not in PATH: ghostcript
-> As a result, figure cropping will be disabled.
Execution halted
Any help or try to troubleshoot would be appreciated. Thank you
I have figured this out for myself by now: what I did was that I first uninstalled MikTex and tinytex because they apparently were clashing somehow. Then I reinstalled tinytex - this time typing it directly into the console instead of using the installing tool from R - so I typed everything at a time and executed it. It had me restart R and updated some files then too. Since then it has worked flawlessly. Also, I did the same on my other computer (MacBook) where it didn't work so chances are pretty good that that might solve that same problem for someone else out there. Thanks to everybody who tried helping and improved the question or sent responses.
Which code you tried to compile?
Sometimes this error rise when a letter is missed in the \begin function. If you tried to compile an array, do not forget to use the same letters as rows you need.
Example:
$$|x|=\left\{\begin{array}{ll} -x & \text{si }x\le 0\\ x & \text{si }x\ge 0 \end{array}\right.$$

RMarkdown not compiling into PDF

I need to use RMarkdown to compile into one pdf but its not working. All my scripts work perfectly on their own but dont want to create the pdf in RMarkdown. What do I need to do, I don't use RMarkdown enough to know what to do.
Here is my error output:
output file: R-Markdown-Midterm.knit.md
A new version of TeX Live has been released. If you need to install or update any LaTeX packages, you have to upgrade TinyTeX with tinytex::reinstall_tinytex(). If it fails to upgrade, you might be using a default random CTAN mirror that has not been fully synced to the main CTAN repository, and you need to wait for a few more days or use a CTAN mirror that is known to be up-to-date (see the "repository" argument on the help page ?tinytex::install_tinytex()).
tlmgr: Local TeX Live (2019) is older than remote repository (2020).
Cross release updates are only supported with
update-tlmgr-latest(.sh/.exe) --update
See https://tug.org/texlive/upgrade.html for details.
! LaTeX Error: File `xcolor.sty' not found.
! Emergency stop.
<read *>
Error: LaTeX failed to compile R-Markdown-Midterm.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See R-Markdown-Midterm.log for more info.
In addition: Warning messages:
1: In in_dir(input_dir(), evaluate(code, envir = env, new_device = FALSE, :
You changed the working directory to /Users/eruiz/Desktop/Stevens/Summer 2020/FE630 Portfolio Theory and Applications/Midterm/Summer 2020/Code (probably via setwd()). It will be restored to /Users/eruiz/Desktop/Stevens/Summer 2020/FE630 Portfolio Theory and Applications/Midterm/Summer 2020. See the Note section in ?knitr::knit
2: In in_dir(input_dir(), evaluate(code, envir = env, new_device = FALSE, :
You changed the working directory to /Users/eruiz/Desktop/Stevens/Summer 2020/FE630 Portfolio Theory and Applications/Midterm/Summer 2020/Code (probably via setwd()). It will be restored to /Users/eruiz/Desktop/Stevens/Summer 2020/FE630 Portfolio Theory and Applications/Midterm/Summer 2020. See the Note section in ?knitr::knit
3: In system2("tlmgr", args, ...) :
running command ''tlmgr' search --file --global '/xcolor.sty'' had status 1
Execution halted

Workaround to allow badges in package README.md on github but not in CRAN version

R CMD check packagename_0.1.1.tar.gz --as-cran produces a WARNING if badges are present in README.md. This causes consequences like travis CI to fail (since it treats warnings as errors)
Is there a workaround to get the check to pass without removing the badges?
Here is an example of the WARNING I see
* checking top-level files ... WARNING
Conversion of ‘README.md’ failed:
pandoc: Could not fetch https://www.r-pkg.org/badges/version/bigrquery
TlsExceptionHostPort (HandshakeFailed (Error_Misc "user error (unexpected type received. expecting handshake and got: Alert [(AlertLevel_Fatal,HandshakeFailure)])")) "www.r-pkg.org" 443
Related: pandoc: Could not fetch http://www.r-pkg.org/badges/version/package TlsExceptionHostPort (HandshakeFailed
This is a workaround to embed (static) badges in pages. They do not auto-update. The purpose is to avoid offline derived errors.
Take a look at readme files in:
https://gitlab.com/ferroao/idiogramFISH. This also handles errors while installing with devtools in windows, a process that does not have online connectivity (see vignette index.Rmd). Look at DESCRIPTION also if you want to see dependencies and vignette builders.
Generate the .md from the .Rmd (Rmarkdown).
Months on, I discovered the problem. When I installed anaconda, it changed the version of pandoc my system used - which pandoc should return something like /usr/local/bin/pandoc (and not like /Users/st/anaconda3/bin/pandoc).
In my case, I edited by .bash_profile to exclude ananconda, closed and reopened the terminal and everything worked. (I also reinstalled pandoc from here, but I don't think that had anything to do with fixing it - it did show me the default installation location though)

Trouble with Pandoc installation on Ubuntu 14.04LTS for using with R Markdown

This question is a corollary of my attempts to get some experience with creating reproducible reports from R Markdown documents via knitr and rmarkdown R packages. While it seems that .Rmd => HTML conversion is automated from within RStudio (Knit HTML button), my attempt to do the same outside of RStudio (Rscript -e 'library(rmarkdown); render("knitr-example-slides-1.Rmd")') failed due to, according to the message, lack of pandoc on my system. This is most likely false, since RStudio somehow managed to perform the conversion. Therefore, it is most likely an access and/or path issue.
Without knowledge of where RStudio maintains pandoc and details about the access, I have decided to install pandoc myself. Unfortunately, sudo apt-get install pandoc has not been very helpful, due to the fact that current version of pandoc in Ubuntu's trusty repository (14.04LTS) is 1.12.2.1. According to rmarkdown's message, version 1.12.3 or higher is required. "Not a big deal", I have thought, and followed instructions on installing pandoc in case of too old version in repository (http://johnmacfarlane.net/pandoc/installing.html). That requires installing the Haskell platform, which is pretty big and which output is rather verbose. After some time, I finally has been greeted with the following failure message:
[ 6 of 57] Compiling Text.Pandoc.Readers.TeXMath ( src/Text/Pandoc/Readers/TeXMath.hs, dist/build/Text/Pandoc/Readers/TeXMath.o )
src/Text/Pandoc/Readers/TeXMath.hs:30:38:
Ambiguous occurrence `readTeXMath'
It could refer to either `Text.Pandoc.Readers.TeXMath.readTeXMath',
defined at src/Text/Pandoc/Readers/TeXMath.hs:56:1
or `Text.TeXMath.readTeXMath',
imported from `Text.TeXMath' at src/Text/Pandoc/Readers/TeXMath.hs:33:1-19
(and originally defined in `Text.TeXMath.Parser')
Failed to install pandoc-1.12.4.2
cabal: Error: some packages failed to install:
pandoc-1.12.4.2 failed during the building phase. The exception was:
ExitFailure 1
pandoc-citeproc-0.3.1 depends on pandoc-1.12.4.2 which failed to install.
Firstly, I'm not sure how to fix it. Secondly, I very much suspect that there should be an easier way to enjoy generating reproducible reports with rmarkdown and pandoc than this. Your advice will be appreciated!
UPDATE (see comments):
Rscript -e 'library(rmarkdown); render("knitr-example-slides-1.Rmd")'
processing file: knitr-example-slides-1.Rmd
|....... | 11%
ordinary text without R code
|.............. | 22%
label: setup (with options)
List of 1
$ include: logi FALSE
Quitting from lines 6-8 (knitr-example-slides-1.Rmd)
Error in eval(expr, envir, enclos) : object 'opts_chunk' not found
Calls: render ... handle -> withCallingHandlers -> withVisible -> eval -> eval
Execution halted
Basically, #daroczig answered this question in his comment above, so I will repeat it here, plus will add an answer to the relevant minor question on the issue, appeared after the main question's issue fix.
1) "A binary compiled version of Pandoc is already shipped with RStudio, so you can simply create a symlink, so that you could easily use that outside of the RStudio eco-system: https://github.com/rstudio/rmarkdown/blob/master/PANDOC.md#newer-systems-debianubuntufedora";
2) I have fixed the error, experienced after applying the advice above (see my comment), by calling opts_chunk() using explicit package reference: knitr::opts_chunk(), following guidelines here: http://rmarkdown.rstudio.com/authoring_migrating_from_v1.html (thanks to #Yihui for pointing me to this document in a different question: Transitioning research project to knitr-based setup).

Resources