MacLochlainns Weblog

Michael McLaughlin's Technical Blog

Site Admin

Archive for the ‘R Development’ tag

Ubuntu, R, RScript & RStudio

without comments

Installed R, Rscript, and RStudio on my student Ubuntu instance. You use the following command to install R a

sudo apt install -y r-base-core

Then, you can check the version with the following command:

R --version

It should return:

R version 4.1.2 (2021-11-01) -- "Bird Hippie"
Copyright (C) 2021 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/.

You also can run the interactive R environment by simply typing “R” at the command-line interface (CLI). It will display the following after entering the environment, quitting the environment, and discarding the workspace:

R version 4.1.2 (2021-11-01) -- "Bird Hippie"
Copyright (C) 2021 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 certain conditions.
Type 'license()' or 'licence()' for distribution details.
 
  Natural language support but running in an English locale
 
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
 
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
 
> q()
Save workspace image? [y/n/c]: n

You can write and run a hello.r script file as follows in a Linux environment:

#!/usr/bin/Rscript
 
# Print a string.
print("Hello World!")

It prints what you would expect:

[1] "Hello World!"

The RStudio comes in two versions. One is Free and the other costs money. These are not hosted in the Ubuntu repository, and you must download them manually to apply them. You can go to RStudio web site or run the following command to download RStudio Free edition:

wget https://download1.rstudio.org/electron/jammy/amd64/rstudio-2023.12.0-369-amd64.deb

After downloading the package, you can’t quite install RStudio until you install two likely uninstalled dependencies, which are:

libclang-dev
libclang-14-dev
libclang1-14
libclang-common-14-dev
lib32gcc-s1
lib32stdc++6
libc6-i386
libobjc4
libobjc-11-dev  
libssl-dev

Therefore, the prestep is:

sudo apt install -y libssl-dev libclang-dev libclang-14-dev libobjc-11-dev libclang1-14 libclang-common-14-dev lib32gcc-s1 lib32stdc++6 libc6-i386 libobjc4

Then, you can install RStudio with this command from the directory where you downloaded it:

sudo dpkg -i rstudio-2023.12.0-369-amd64.deb

After a successful installation, you can launch RStudio with the following command:

rstudio

You will get the following console:

As always, I hope this helps those trying to do something that should be simple but isn’t quite simple.

Written by maclochlainn

January 10th, 2024 at 12:43 am

Posted in Linux,R,Ubuntu

Tagged with