ESS mode R: how to do a javareconf? - r

In order to load R with a functional rJava, I need to run R CMD javareconf first. This works if I run R from the shell, but I want to run it in ESS. How can I get ESS (that is, M-x R) to run with the effects of the javareconf?
System information:
OpenSUSE 12.2 x 64
Emacs version 24.2.1
R patched: 3.0.1 "Good Sport"

Related

Runing an R Script that includes messageboxes from the windows terminal

I am trying to run a simple R Script that creates a messagebox using the R library svDialogs:
library(svDialogs)
user.input <- dlgInput("Enter a number", Sys.info()["user"])$res
This runs well whe I execute it using RStudio for example:
RStudio 2922.02.1 Build 461, using
R version 3.6.1 (2019-07-05) -- "Action of the Toes"
Platform: i386-w64-mingw32/i386 (32-bit)
However, I have also tried to run this using a .bat file:
"Path_to_Rscript\Rscript.exe" Path_to_File\File.r
I have used .bat files to automate the sequential execution of RScripts from different R installations and Architectures (32Bit and 64bit), but I am having problems executing RScripts that require showing these messageboxes to either show data or to require input from users.
What am I doing wrong?

Change R version of the shell on Mac

my R version on the zsh shell is the 3.6 that is different respect to the one of RStudio that is the 4. In fact, using the Jupyter notebook, the R version is the one used by conda. In fact, to install an r package I must run conda install -c r r-package_name. So, this is very annoying. How can I link the R version of Rscript of the shell with the one of the Rstudio?

Source .bashrc in Rstudio

I have just installed some Perl modules locally in Ubuntu 18.04 LTS.
When calling them using the RStudio Server like this
system("perl -MBio::TreeIO -e 1")
I get the following error
Can't locate Bio/TreeIO.pm in #INC (you may need to install the Bio::TreeIO module) (#INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.26.1 /usr/local/share/perl/5.26.1 /usr/lib/x86_64-linux-gnu/perl5/5.26 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.26 /usr/share/perl/5.26 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base)
When I source ~/.bashrc in the terminal everything's ok.
I tried creating a ~/.Rprofile containing:
system(". ~/.bashrc")
but no good.
According to the documentation, accessed by running help(Startup) in the R shell, you should create a file .Renviron in your home directory which will be read when starting up a new R session. For example:
.Renviron
FOOBAR=/foo/bar/foo/bar
R shell
R
R version 3.2.3 (2015-12-10) -- "Wooden Christmas-Tree"
Copyright (C) 2015 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
...
> cat(Sys.getenv("FOOBAR"), "\n")
/foo/bar/foo/bar
So just create your .Renviron file with the PERL5LIB variable set to your local perl package installation directory.

Multiple versions of R installed - terminal launching wrong / different R from RStudio

I am attempting to compile my R package, and realized that I have multiple versions of R installed on my mac, which is giving me difficulty. When I run 'which R' from terminal, I receive this:
Home$ which R
/Users/Home/anaconda2/bin/R
Home$ R
R version 3.2.2 (2015-08-14) -- "Fire Safety"
However, when I launch RStudio from my applications folder, and type 'version' in the console, I get this:
> version
_
platform x86_64-apple-darwin13.4.0
arch x86_64
os darwin13.4.0
system x86_64, darwin13.4.0
status
major 3
minor 3.2
year 2016
month 10
day 31
svn rev 71607
language R
version.string R version 3.3.2 (2016-10-31)
nickname Sincere Pumpkin Patch
So I have 3.3.2 on RStudio (the version I want for compiling my package), and 3.2.2 from anaconda being launched in terminal when I type R in terminal.
How can I fix this? Do I have to change my path to find the correct version of R when I launch from terminal? How do I find the correct path?
Thanks!
I bet anaconda has just inserted its path at the front of your PATH variable and is overriding your newer 3.3.2 version at the terminal. If you want your 'RStudio' version to be the default version that pops up at your terminal when you type 'R', then you gotta modify your PATH. No biggie.
First, figure out which R version RStudio points to. Type the following into your RStudio console:
Sys.which("R")
I bet you'll see something like /usr/local/bin/R. So that's what you have to add to the front of your PATH (minus the '/R').
To confirm that anaconda has messed you up, open up your terminal and check out your PATH:
echo $PATH
You'll probably see /Users/YOURNAME/anaconda2/bin as the first entry in your PATH, and further down you'll see /usr/local/bin. We have to flip this order. There are a million ways to fix this. Here's the quick and dirty solution -- add the following to the bottom of your .bash_profile
export PATH="/usr/local/bin:$PATH"
And type R --version in your terminal to confirm that your default R has changed.
You might get fancy later with sed or awk if having two /usr/local/bin entries in your PATH annoys you (as it would me).
First go to the directory /Library/Frameworks/R.framework/Versions
Here you should see various versions of R that you have installed.
To change to say version 3.4 use the following sequence of commands in the Terminal:
cd /Library/Frameworks/R.framework/Versions
unlink Current
ln -s 3.4 Current
I highly recommend RSwitch. It's a tiny program that allows you to select from any installed R version, press one button, restart your R session and you'll be using the selected R version.

Why is RStudio running a different version of R when I run as an admin?

When I call sudo rstudio in Terminal, it runs off of the CRAN R version, but if I just run rstudio it runs off of Microsoft R Open.
Why could this be?

Resources