I am sure this is a trivial question, but I am trying to install multiple R versions in Linux. I am not using R studio server pro and am instead using the free R studio server. I followed this documentation to install R but got errors when I attempted to locate it. However, when I run a command to see what version of R is installed, there is no error.
R is installed!
(base) noah#noah-VirtualBox:/opt/R/4.1.3$ /opt/R/4.1.3/bin/R --version
R version 4.1.3 (2022-03-10) -- "One Push-Up"
Copyright (C) 2022 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under the terms of the
GNU General Public License versions 2 or 3.
For more information about these matters see
https://www.gnu.org/licenses/.
Attempts
(base) noah#noah-VirtualBox:/opt/R/4.1.3$ R
Command 'R' not found, but can be installed with:
sudo apt install r-base-core
(base) noah#noah-VirtualBox:/opt/R/4.1.3$ which R
(base) noah#noah-VirtualBox:/opt/R/4.1.3$
Steps to reproduce
export R_VERSION=4.1.3
curl -O https://cran.rstudio.com/src/base/R-4/R-${R_VERSION}.tar.gz
tar -xzvf R-${R_VERSION}.tar.gz
cd R-${R_VERSION}
# Build and install R
./configure \
--prefix=/opt/R/${R_VERSION} \
--enable-memory-profiling \
--enable-R-shlib \
--with-blas \
--with-lapack
make
sudo make install
# Verify R installation
/opt/R/${R_VERSION}/bin/R --version
# Create a symlink to R
sudo ln -s /opt/R/${R_VERSION}/bin/R /usr/local/bin/R
sudo ln -s /opt/R/${R_VERSION}/bin/Rscript /usr/local/bin/Rscript
# Export path so Rstudio can find it
export RSTUDIO_WHICH_R='/opt/R/4.1.3/bin'
You are overcomplicating it. Just install in, say,
/opt/R/4.2.0/
/opt/R/4.1.2/
/opt/R/4.0.5/
and then either set the $PATH to the bin/ directory in the version you want, or call R directly. It is what pretty much exactly what many of us have done with two versions of R (i.e. R-release and R-devel):
$ R --version | head -1
R version 4.2.0 (2022-04-22) -- "Vigorous Calisthenics"
$
$ /usr/lib/R/bin/R --version | head -1
R version 4.2.0 (2022-04-22) -- "Vigorous Calisthenics"
$
$ /usr/local/lib/R-devel/bin/R --version | head -1
R Under development (unstable) (2022-05-24 r82398) -- "Unsuffered Consequences"
$
The first two are the same as that is my 'default' version. The third is my one alternate. And that is all there is to it.
If you add /usr/local/bin to your $PATH variable you would have been able to launch R, if it was not already present.
You could add it to .bashrc in your home directory
echo "export path=\"${PATH}:/usr/local/bin\"" |tee -a ~/.bashrc
Links for installing R from package, Ubuntu / Debian, RHEL 9, RHEL 8, RHEL/CentOS7
https://docs.posit.co/resources/install-r/
Also see
(Optional) Install multiple versions of R, on the same page.
Related
I have installed r-integration via npm. I have placed my R script inside the node-server directory which is located at srv/nodeserver/. I have R installed in my machine.
> whereis R
R: /usr/bin/R /usr/lib/R /etc/R /usr/local/lib/R /usr/share/R /usr/share/man/man1/R.1.gz
The nodejs REST API code looks like below:
app.get('/getRresult',(req,res)=>{
let result = R.executeRScript(
'server.R',"circumference",{r:2});
console.log(result)
});
When I hit the RESTAPI url I get the following error:
Error: R not found, maybe not installed.
However R is installed because if I type R in the terminal R shell opens up. I tried exporting the path of usr/bin/R in ~/.bashrc. It still does not seem to work. I am confused which path will actually work or how to set the path for ubuntu PATH variable.
You needs to install R on your ubuntu.
Here are steps
#1 Install the dependencies necessary
to add a new repository over HTTPS:
$ sudo apt install dirmngr gnupg apt-transport-https ca-certificates software-properties-common
#2 Add the CRAN repository to your system sources’ list
$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
$ sudo add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/'
#3 Install R
$ sudo apt install r-base
#4 Verify R version
R --version
Terminal Output
$ R --version
R version 3.6.3 (2020-02-29) -- "Holding the Windsock"
Copyright (C) 2020 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under the terms of the
GNU General Public License versions 2 or 3.
For more information about these matters see
https://www.gnu.org/licenses/.
#5 Finally run simple example
test.js will call test.R by R.executeRScript()
It will return value into test.js then it will console.log()
file name save as test.js
const R = require('r-integration');
let result = R.executeRScript("./test.R");
console.log(result);
file name save as test.R
x <- 5
y <- 6
z <- 3
result <- max(x, y, z)
print(result)
Install r-integration library
npm install r-integration
Run it and see the Result
$ node test.js
[ 6 ]
References
R-integration - Node JS API
How to Install R on Ubuntu 20.04
I installed Rstudio using anaconda. I think the R was also installed alongside with it (but I read somewhere that Rstudio doesn't come with R: Tell me if I am wrong).
From terminal: which R shows :/home/simo/anaconda3/bin/R.
I tried that:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
sudo echo "deb http://cran.wustl.edu/bin/linux/ubuntu bionic-cran35/" | sudo tee -a /etc/apt/sources.list
sudo apt update
sudo apt upgrade
but doesn't upgrade the version of R (still R version 3.5.1 (2018-07-02) -- "Feather Spray")
At the first place I want to install: dashHtmlComponents, a dash library.
> install.packages("dashHtmlComponents")
Warning message:
package ‘dashHtmlComponents’ is not available (for R version 3.5.1)
>
But from the dash documentation I read that at least version 3.0.2 of R is required.
What is wrong?
It depends what OS you are on how you would go about doing that. The particular methods for Windows and MacOS are laid out on this page.
As far as if you have R (which it appears you do, but nonetheless), you can run install r-essentials --yes in the terminal (Mac) or Anaconda Prompt (PC). In Linux you can follow the steps here.
Once you do either of these, you should be able to use install.packages('dashHtmlComponents'). I am using R version 3.6.2 and it installs just fine.
I'm trying to install gifski which is a dependency for gganimate.
I get this error.
------------------ RUST COMPILER NOT FOUND --------------------
Cargo was not found on the PATH. Please install cargo / rustc:
- yum install cargo (Fedora/CentOS)
- apt-get install cargo (Debian/Ubuntu)
- brew install rustc (MacOS)
Alternatively install Rust from: <https://www.rust-lang.org>
---------------------------------------------------------------
The yum install cargo command didn't work, so I installed Rust with
curl https://sh.rustup.rs -sSf | sh
The installation prompt said I needed to add $HOME/.cargo/bin to my path environment variable, so I tried this.
$ source $HOME/.cargo/env
$ export PATH=$PATH:$HOME/.cargo/bin
$ export PATH=$PATH:/.cargo/bin
$ export PATH=$HOME/.cargo/bin
I reset my machine and I continue to receive the same error.
> sessionInfo()
R version 3.5.3 (2019-03-11)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Amazon Linux AMI 2018.03
I'm having trouble trying to install R 3.0.2 in Ubuntu 16.04. I tried adding the repositories of older versions of R but the package for R 3.0.2 cannot be found in apt-get. Has anyone tried installing an older version of R on a newer version of Ubuntu? May I know what the steps are?
I tried also specifying the version in the apt-get install command but it didn't find the right package.
I see the best option in your case is to compile R. If you have never done such a thing, follow this little script in terminal:
# install common R dependencies
sudo apt-get install gcc \
g++ \
gfortran \
bzip2 \
libbz2-dev \
xorg-dev \
liblzma-dev \
libreadline-dev \
libpcre++-dev \
libcurl-dev \
libpango1.0-dev
mkdir R_alternatives
cd R_alternatives
mkdir src
mkdir 3.0.2
cd src
wget https://cran.r-project.org/src/base/R-3/R-3.0.2.tar.gz
tar -xvf R-3.0.2.tar.gz
cd R-3.0.2
#In my opinion is better to compile in one folder (avoid uncompress tar.gz source again, if you get any errors)
mkdir BuildDir
cd BuildDir
# this step will take around 2 minutes
./../configure --with-readline=no --with-x=no --prefix=/home/'user'/R_alternatives/3.0.2
# These two will take longer!!
make
make install
# following the prefix in 'configure' your R libraries are going to be installed in /home/'user'/R_alternatives/3.0.2/lib64/R/library/
# Hence, each time you compile a new R version, it will have its own libraries (this avoid R packages versions problems)
# If you wish more than one library version for the same R version, you must create a new folder and then run
export R_LIBS=/'path_to_your_new_folder'
# If you plan to use this R version in RStudio, you have to edit ~/.bash_profile, therefore you must run:
vi ~/.bash_profile
#or, It is up to you!
gedit ~/.bash_profile
#Then you put this line in end of the file
PATH=/home/'user'/R_alternatives/3.0.2/bin:$PATH
export PATH
# OR...
RSTUDIO_WHICH_R=/home/'user'/R_alternatives/3.0.2/bin/R
export RSTUDIO_WHICH_R
#PS: You can also set the R_LIBS here, in the same way!
First off, see here for a similar & older question on SO.
Pre-compiled binaries of older R releases for various Ubuntu versions (mostly the LTS releases) are available as deb's from the following website:
https://cran.r-project.org/bin/linux/ubuntu/
Unfortunately, there doesn't seem to exist a R 3.0.2 deb package for xenial; only precise still has the R 3.0.2 package. You could try to install the precise package in xenial, but that may come with its own problem set.
Might be best to compile from source following Facottons advice.
How do I uninstall R from my MacBook Pro OSX 10.9.2?
I need to reinstall a later version (The version for the Mavericks operating system.)
Sincerely
Joe Mark
In the "R Installation and Administration" manual says next:
If you want to get rid of R more completely using a Terminal, simply
run (prepend sudo if needed):
rm -rf /Library/Frameworks/R.framework /Applications/R.app \
/usr/bin/R /usr/bin/Rscript
If be exactly, from that point:
http://cran.r-project.org/doc/manuals/r-release/R-admin.html#Uninstalling-under-OS-X
UPD: updated link to R uninstalling section