r - Rd2pdf error about TeX binary - r

I created an R package in RStudio using devtools and roxygen2. I have the project file open and I now want to take all of the documentation for my functions and put it together into a pdf reference manual. I ran
system("R CMD Rd2pdf .")
which gave me the following error:
# Error in texi2dvi(file = file, pdf = TRUE, clean = clean, quiet = quiet, :
# Running 'texi2dvi' on 'Rd2.tex' failed.
# Output:
# You don't have a working TeX binary (tex) installed anywhere in
# your PATH, and texi2dvi cannot proceed without one. If you want to use
# this script, you'll need to install TeX (if you don't have it) or change
# your PATH or TEX environment variable (if you do). See the --help
# output for more details.
# For information about obtaining TeX, please see http://www.tug.org. If
# you happen to be using Debian, you can get it with this command:
# apt-get install tetex-bin
# Error in running tools::texi2pdf()
I'm using OS X 10.10 and I have MacTeX installed (it's sitting in my Applications folder). I'm a beginner at R and LaTeX so I'm not sure what the error message means when it says that I don't have a working TeX binary installed. How should I proceed?

After digging around, I found out that the error I was getting has to do with the
Yosemite upgrade.
The workaround is to launch RStudio from terminal as suggested on here.
When I did this, I was able to produce the reference manual just fine.

Related

rmarkdown::render() in cmd returns pandoc error

I need to render forms with rmarkdown from a command line
this is where I am:
knit button in RStudio works fine
function rmarkdown::render(file.rmd) in a .r file works when run in Rstudio
Then I tried running this command in CMD
c:\Program Files\R\R-4.0.2\bin\Rscript.exe" -e "rmarkdown::render('C:/file.rmd')
and I get this error:
Error: pandoc version 1.12.3 or higher is required and was not found (see the help page ?rmarkdown::pandoc_available).
In RStudio I sent
> rmarkdown::pandoc_available()
[1] TRUE
> rmarkdown::pandoc_version()
[1] ‘2.7.3’
What am I missing here?
By the way, I'm on Win10.
Thanks.
There might be an issue wit h Pandoc version, obviously. But maybe some library requires that older pandoc version, and the issue comes from you using Rmarkdown from outside Rstudio.
This link has the answer
Go into Rstudio and type
Sys.getenv("RSTUDIO_PANDOC")
Now take the output from the command above and put it here
Sys.setenv(RSTUDIO_PANDOC="OUTPUT FROM ABOVE COMMAND")

pdfpages Latex package not found

I am trying to compile a pdfbook using R-markdown. After I knit I get the following error:
! LaTeX Error: File `pdfpages.sty' not found.
I loaded tiny text using library(tinytex) to help me install the package pdfpages but continue to have the same error. I resorted to running Rstudio in administrator mode and try the preceding step and running the following tinytex::parse_install(text="! LaTeX Error: File `pdfpages.sty' not found.") (as suggested in Yihui in bookdown). Both resulted in the same error.
Any other suggestion on what is wrong? The package is clearly installed, so I do not know what else can the error be.
Generally when you get an error like pdfpages.sty not found, you need to install the package. From the command line (assuming the Tex bin is in your path) use "tlmgr install pdfpages". Yihui Xie called it "TinyTex" because it was a minimal install compared to something like MacTeX or TexLive.

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

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()

RStudio can't find LaTeX after Mavericks update

I have been using Sweave for quite sometime on my system using RStudio.
However, I recently upgraded my Mac OS from Lion to Mavericks.
This caused several issues:
First, RStudio was not able to locate the R library, and it just wont start. I reinstalled RStudio, but still got the same issue. So I reinstalled both R and RStudio, and then RStudio started to work.
And now, RStudio is still not able to locate TeX installation, and gives me the following warning:
"No TeX installation detected. Please install TeX before compiling."
This will probably get fixed by a reinstall, but I would prefer to avoid a fresh download of TeX (~2.3G).
Any ideas on how to resolve this?
RStudio expects pdflatex to be on the system path (i.e. entering Sys.which("pdflatex") at the R console should return the path to pdflatex).
You can fix the problem by getting pdflatex back on the system path:
Find the path where pdflatex is installed on your system--likely /usr/texbin, but use find /usr -name pdflatex if you need help.
Create a file called TeX in /etc/paths.d that contains this path.
For example:
$ sudo -s "echo /usr/texbin > /etc/paths.d/TeX"
You'll need to restart to apply the changes.

Resources