LyX R 3.4.3 Rscript.exe i386/X64 broken script - r

I ran into this today. I installed R 3.4.3 along side R 3.4.1 . Using LyX/knitr under R 3.4.1 everything was fine. After adding R 3.4.3, changing the System/User/LyX PATH entries from 3.4.1 to 3.4.3, LyX launches Rscript, but it can no longer open the Rnw file in the TEMP folder. LyX freaks out and pops up an error message. My work around was to copy Rscript from R 3.4.1 and everything works again.
Did the command line parameters change from R-3.4.1 toR-3.4.3 ?
Everything seems fine for Rstudio and report compilation. Do the LyX Rscript command line parameters need to be changed for R-3.4.3 ? This occurred under Windows 10 on a X64 laptop and i386 tablet. It's consistent anyway!
Is there a fix for R-3.4.3 or LyX 2.2.3 ?
Updated info:
The LyX console reports the following:
18:10:32.825: Rscript --verbose --no-save --no-restore "C:/Users/dave/AppData/Local/LyX 2.2/Resources/scripts/lyxknitr.R" "C:/Users/dave/AppData/Local/Temp/lyx_tmpdir.WeWWkafx7016/lyx_tmpbuf0/""DES-knitr.Rnw" "C:/Users/dave/AppData/Local/Temp/lyx_tmpdir.WeWWkafx7016/lyx_tmpbuf0/""DES-knitr.tex" ISO-8859-15 "C:/Users/dave/LaTeX Work/Lyx Work/"
18:10:33.241: The filename, directory name, or volume label syntax is incorrect.
support/Systemcall.cpp (291): Systemcall: 'Rscript --verbose --no-save --no-restore "C:/Users/dave/AppData/Local/LyX 2.2/Resources/scripts/lyxknitr.R" "C:/Users/dave/AppData/Local/Temp/lyx_tmpdir.WeWWkafx7016/lyx_tmpbuf0/""DES-knitr.Rnw" "C:/Users/dave/AppData/Local/Temp/lyx_tmpdir.WeWWkafx7016/lyx_tmpbuf0/""DES-knitr.tex" ISO-8859-15 "C:/Users/dave/LaTeX Work/Lyx Work/"' finished with exit code 1
Error: Cannot convert file
----------------------------------------
An error occurred while running:
Rscript --verbose --no-save --no-restore $$s/scripts/lyxknitr.R
"C:/Users/dave/AppData/Local/Temp/lyx_tmpdir.WeWWkafx7016/lyx_tmpbuf0/""DES-kn…
18:10:41.526: Error while exporting format: PDF (pdflatex)
The tempfile exists and I can read it in Notepad++. Note that LyX works fine, R-3.4.3 works fine, but the LyX->Knitr->R->LaTeX-> PDF chain is broken in Rscript. For every installed R upgrade, I've changed the System/User/LyX PATH variables and everything has been fine with knitr until now. My next step is to completely uninstall LyX and R-3.4.3 and reinstall. I'm a little hesitant to proceed with that if I have a simple configuration change/error that may appear again in future upgrades to LyX (2.3) and R (3.4.3+).

I think the problem is that there are two different bin directories for R, one for x64, and one for i386.
So make sure LyX is configured to use the i386 path if you are on a 32 bit machine, e.g.
C:\R\bin\i386\

Related

How to install RGui to update R version

This may be an odd question: where do I find RGui?
I want to update my R-version from 4.1.2 to 4.2. I found this website which uses RGui. However I cannot find a RGui in my Windows Start Menu and searching the web yields this.
I believe I have to install any RGui and run the installation commands, is this correct? If so, can you recommend a software?
Rgui comes with R. There is nothing extra to install to run it. You do not need RStudio in order to run Rgui. RStudio is a front end to R that is separate from Rgui and is an alternative to Rgui . Unlike Rgui, RStudio does not come with R.
To get a desktop icon, run the R installer again and make sure you have the item checked for a Desktop Icon.
To locate Rgui.exe try this from the Windows cmd line assuming R is installed in the standard location.
cd C:\Program Files\R
dir /b /s Rgui.exe
Also if Rgui is already on your path then running this from the Windows cmd line should find it.
where Rgui.exe

Difficulty Running Multiple Versions of R from Command Line

I'm in a team that is running multiple cronjobs that call R scripts from a remote machine (macos). My colleague needs to run 3.6 for a new script, while a package that is essential to mine has not been updated for it yet. I'm trying to put multiple installations on the same computer so we just specify which "R" version to call in the cronjob.
I know installing from source isn't recommended on macos, so I've been trying to follow the directions here https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Multiple-versions and ran the pkgutil --forget commands to prevent the R 3.6 installation from overwriting the R.framework/Versions/3.5 directory.
Here are the pkgutil commands that I ran:
sudo pkgutil --forget org.r-project.x86_64.tcltk.x11
sudo pkgutil --forget org.r-project.R.el-capitan.GUI.pkg
sudo pkgutil --forget org.r-project.R.el-capitan.fw.pkg
sudo pkgutil --forget org.r-project.x86_64.texinfo
Yet after installing 3.6 from CRAN, when I run the following line:
Library/Frameworks/R.framework/Versions/3.5/Resources/bin/R
Instead of the 3.5.3 console running in the terminal, the 3.6 console pops up.
I'm confused with what to do here - I've also used
ls -la 3.5/Resources/bin | grep "/->"
to check and see if a symlink was created during the install that would change the version/location but get no results, and when I run Rscript --version in the same directory as the R path shown above, I get the following output:
R scripting front-end version 3.5.3 (2019-03-11)
Though when I try to run my script using this location of Rscript I get the same error that I did when running it using R 3.6. However, once I reinstalled R 3.5.3 the script ran fine.
Basically, I think somehow the most recently installed version of R seems to override and run no matter what I do to try and insure that an older version runs instead. Can someone help me piece together how or why this is happening, or provide a suggestion as to how to install R 3.6 as the default "R" while still allowing me to run 3.5.3 for certain scripts as needed?
I have similar problem. What you observed is clearly mentioned on https://cran.rstudio.org/doc/manuals/R-admin.html#Uninstalling-under-macOS: "However, R.APP will always run the ‘current’ version, that is the last installed version.". So far, I don't know how to solve the problem either. Using Rswitch worked very well to switch R versions manually, but i don't know how to integrate Rswitch to command lines.

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