Rstudio / pandoc issue - can't knit to HTML or PDF - r

I can't knit to HTML or PDF anymore, although it used to work just fine. Here's the error I keep getting:
pandoc: out of memory (requested 1048576 bytes)
Error in strsplit(version_info, "\n")[[1]] : subscript out of bounds
Calls: <Anonymous> ... pandoc_available -> find_pandoc -> lapply -> FUN -> get_pandoc_version
In addition: Warning message:
running command ''/usr/lib/rstudio/bin/pandoc/pandoc' --version' had status 1
Execution halted
I used to have Rstudio 0.999.903, which I uninstalled, I then installed 1.0.44 version, reinstalled the knitr package through Rstudio, but I'm getting this error again.
I installed pandoc 1.18-1 from the git repository using the debian package installer, same problem again.
I later updated Rstudio to version 1.0.136 and pandoc to version 1.19.2.1 and no change.
I tried uninstalling R and re-installing a more recent version, again with no success.
The command-line works:
library(rmarkdown)
rmarkdown::render("test.Rmd", "html_document")
--
I'm using Debian (LMDE2).

Finally I got it!
It seems this bug was described 2 years ago by Arch users here.
It seems this bug was introduced for me with Rstudio version 0.98+ in a Debian system (I use LMDE Betsy).
The pandoc version installed along with Rstudio doesn't work, and when I installed pandoc manually Rstudio would stick to using its own broken version. Anyway the workaround is to remove the executable pandoc from Rstudio distro, and symlink another version of pandoc instead:
apt-get install pandoc
rm /usr/lib/rstudio/bin/pandoc/pandoc
ln -s /usr/bin/pandoc /usr/lib/rstudio/bin/pandoc/pandoc
rm /usr/lib/rstudio/bin/pandoc/pandoc-citeproc
ln -s /usr/bin/pandoc-citeproc /usr/lib/rstudio/bin/pandoc/pandoc-citeproc
I found this workaround here.
The repository has pandoc version 1.12, but more recent versions also work. I am now using pandoc 1.19.2.1 and Rstudio 1.0.136.

Related

RStudio error in windows: Running pdflatex.exe on file_name.tex.. (exit code -1073740791)

I am using Rstudio in windows 10. I am triying to create a pdf from a .tex file. However, when I compile the PDF, the following error appears:
Running pdflatex.exe on file_name.tex...failed Error running C:/Users/user_name/AppData/Local/Programs/MiKTeX/miktex/bin/x64/pdflatex.exe (exit code -1073740791)
I am using a native installation of R, Rstudio and MikTeX. Not an envioronment with anaconda or similar.
If you are using RStudio, have you tried tinytex instead of MikTeX? In the Tools Menu>Global Options>Sweave, tick "use tinytex for compiling .tex files". Then install tinytex package. After installing tinytex package, write in console "tinytex::install_tinytex()". This will install the latex compiler tinytex. Try compiling your tex file using it.
I think that issue has to do with missing packages. In fact, MiKTeX doesnt preinstall most of them. I recommend to compile with TinyTeX, because it shows where the compilation stops (as I said, due to a missing package typically required in some sty file). This way you can track which are the missing packages and install them on the MiKTeX Console one by one.
I posted about this issue in an open discussion on Github. Drop the link here in case you need more details.

Cannot knit Rmd file since I changed the name of User directory

I am using R for windows on RStudio.
I recently changed the name of User directory for a reason, and it seems that the change is causing a problem in knitting Rmd file.
If I try to knit Rmd file, the following error massage appears:
Error: invalid
version specification 'find'
In addition: Warning message:
In system(paste(shQuote(path), "--version"), intern = TRUE) :
running command '"C:/PROGRA~3/CHOCOL~1/bin/pandoc.exe" --version' had status 65535
Execution halted
I entered '"C:/PROGRA~3/CHOCOL~1/bin/pandoc.exe" --version' in cmd, it says
Cannot find file at 'c:\users\MY OLD USER NAME\appdata\local\pandoc\pandoc.exe'
So, I guess that knitr or pandoc is trying to find the wrong path.
How can I fix the problem? How can I change the path?
Here is the list of what I have tried:
Uninstalled R and RStudio, and then installed them.
Then, I installed all the packages needed by install.packeges.
Thus, I am using the latest version of R, RStudio, and packages.
Searched 'pandoc' in registry editor, and tried to find the old path (but I couldn't)
It seems you installed Pandoc by yourself through Chocolatey, and the installation was broken after you changed the name of your User directory.
First, you do not have to install Pandoc separately if you are using RStudio, because RStudio has bundled Pandoc with it.
If you have to install Pandoc for some reason, you may need to reinstall it (perhaps you have to reinstall Chocolatey, too).
choco uninstall pandoc
choco install pandoc

R Notebook Creation Failed

When I go File-New File-R Notebook, it tells me to install some packages, but then it fails giving me this message:
Notebook Creation Failed:
"One of more packages required for R Notebook creation were not installed"
I'm trying to install those packages manually, but the package installation window disappears so quickly that I can't even see which ones I should install.
I googled it around, but couldn't fine any resource.
Can anyone help me with this?
Maybe at least provide a list of packages required to run R Notebook?
R notebooks are actually not created with a package named either RNotebook or notebook or anything similar but rather with the rmarkdown package, and it needs to be a current version. So the command would be:
install.packages("rmarkdown", dependencies=TRUE) # needs to be >= version 1.3
Then your pulldown menu selections should succeed in a current version of RStudio. .... at least that is if you have the system requirements listed in the CRAN webpage:
SystemRequirements: pandoc (>= 1.12.3) - http://pandoc.org
This worked for me:
Install latest version of R from cran website
Start RStudio pointing to this version of R.
On Mac set env variable as show below and start RStudio from terminal
Then "Install Package" in RStudio for "markdown" and other ppackages will work properly installing latest required packages to open notebook
➜ export RSTUDIO_WHICH_R=/usr/local/bin/R
Don't press the error message, and read whatever you can from the installation popup under it. In my case the last message was that it has problems compiling "digest". I installed "digest" manually (install.packages("digest",type = "binary")). Then it all worked.
Mac, R version 3.6, Rstudio desktop 1.2.
I had exactly the same problem. By reading the error logs, I found g++ command not found. So just installed it and it worked fine next time I've tried.
I faced the same problem. I am using the latest version of R and RStudio and all of the installed packages are up-to-date.
Now, talking about the error in installation of packages. Follow the steps below and you will have R Notebook up and running:
Run the command
install.packages("rmarkdown", dependencies=TRUE)
You will observe several messages on the console during installation. Browse through them and jot the ones where there is ERROR in installation of some other dependent package. In my case, it was 'backports'. The error message will be like this:
ERROR: compilation failed for package 'backports'
It can be different in your case but the point is to note down the name of the package that is facing compilation issues. Use an editor(npp) to save the name of the package.
Once you get the name of the package, execute the following command:
install.packages("backports", type="binary")
After successful execution of the above command, go to File drop down and select R Markdown. Go with auto installation of the rmarkdown and rprojroot packages. They will be successfully installed and you can now use R Notebook
Let us know if this solution worked for you.
I just found the answer myself so I'm posting.
I guess there was something wrong with the server.
I went into tools-global options-packages and chose different CRAN mirror, then it worked.
UPDATE YOUR VERSION OF R - that was my solution, I had the same problem.
( First two commands ensure you get the MOST RECENT version of R which I found on a Digital Ocean page)
$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
$ sudo add-apt-repository 'deb [arch=amd64,i386] https://cran.rstudio.com/bin/linux/ubuntu xenial/'
$ sudo apt-get update
$ sudo apt-get install r-base
WITHOUT the first two lines I ended up with R version 3.2.3 (2015-12-10) -- "Wooden Christmas-Tree"
WITH the first two lines I got R version 3.4.4 (2018-03-15) -- "Someone to Lean On"
After reinstalling R Studio, the Files -> RMarkdown was able to install all those subpackages and WORK. Hurray!

Knitting to PDF in R

I am new to R and am trying to knit my R Markdown files into PDF format.
I continually get the error message:
pandoc: pdflatex not found. pdflatex is needed for pdf output.
Error: pandoc document conversion failed with error 41
Execution halted
No TeX installation detected (TeX is required to create PDF output). You should install a recommended TeX distribution for your platform:
Windows: MiKTeX (Complete) - http://miktex.org/2.9/setup
(NOTE: Be sure to download the Complete rather than Basic installation)
Mac OS X: TexLive 2013 (Full) - http://tug.org/mactex/
(NOTE: Download with Safari rather than Chrome strongly recommended)
Linux: Use system package manager
I have downloaded pandoc, and I have also downloaded TexLive and have installed them both onto my computer. For the life of me I cannot figure out why R wont recognize that Ive installed them, and knit into a PDF.
Please help!
For Mac OS X, if you have installed TexLive (I installed so through homebrew caskroom) you should have pdftex available via command line.
type 'which pdftex' to make sure something shows up. from there, i created a symbolic link into my $PATH, specifically into my /usr/local/bin (which is where all my homebrew stuff is stored) with:
ln -s /usr/texbin/pdftex /usr/local/bin/pdflatex
from there, using knitr in RStudio and R in general seemed to work and rendering R Markdown is definitely a really beautiful option (check some of the templates too like the Tufte one!)
I had the same problem, after downloading mactex through FireFox and installing the package.
I quit and restarted RStudio, and it worked (no changes at the terminal command line level).
The .pdf output is, however, a bit blurry at least on my first attempt.
I had a similar issue as I wasn't able to knit pdf file & solved it by installing & running tinitex packages using those commands in the console -- not the terminal
install.packages("tinytex")
tinytex::install_tinytex()

Rmarkdown Pandoc error after update to macOS Catalina (10.15)

I had a simple shell script that ran the following:
Rscript -e 'rmarkdown::render("index.Rmd")'
After updating to macOS Catalina (10.15) I started getting the following error:
Error: pandoc version 1.12.3 or higher is required and was not found (see the help page ?rmarkdown::pandoc_available).
However, if I knit index.Rmd directly in RStudio, it works fine. And, when I check the pandoc version I get:
rmarkdown::pandoc_version()
[1] ‘2.3.1’
But, if I run the following in terminal I get:
Rscript -e 'rmarkdown::pandoc_version()'
NULL
Again, I can knit the file directly in RStudio, but I'm curious why my shell script stopped working and if anyone knows how to fix it.
I also posted this question in the RStudio Community here.
#mattwarkentin posted a solution that worked for me on the RStudio Community page.
Essentially, I just needed to install Pandoc system-wide using Homebrew:
brew install pandoc

Resources