Ubuntu, R, RScript & RStudio
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 |
Display detailed console log →
Reading package lists... Done Building dependency tree... Done Reading state information... Done Suggested packages: libssl-doc The following NEW packages will be installed: lib32gcc-s1 lib32stdc++6 libc6-i386 libclang-14-dev libclang-common-14-dev libclang-dev libclang1-14 libobjc-11-dev libobjc4 libssl-dev 0 upgraded, 10 newly installed, 0 to remove and 14 not upgraded. 1 not fully installed or removed. Need to get 44.2 MB of archives. After this operation, 382 MB of additional disk space will be used. Get:1 http://us.archive.ubuntu.com/ubuntu jammy-updates/main amd64 libssl-dev amd64 3.0.2-0ubuntu1.12 [2,373 kB] Get:2 http://us.archive.ubuntu.com/ubuntu jammy-updates/universe amd64 libobjc4 amd64 12.3.0-1ubuntu1~22.04 [48.6 kB] Get:3 http://us.archive.ubuntu.com/ubuntu jammy-updates/universe amd64 libobjc-11-dev amd64 11.4.0-1ubuntu1~22.04 [196 kB] Get:4 http://us.archive.ubuntu.com/ubuntu jammy-updates/universe amd64 libclang1-14 amd64 1:14.0.0-1ubuntu1.1 [6,792 kB] Get:5 http://us.archive.ubuntu.com/ubuntu jammy-updates/main amd64 libc6-i386 amd64 2.35-0ubuntu3.5 [2,837 kB] Get:6 http://us.archive.ubuntu.com/ubuntu jammy-updates/main amd64 lib32gcc-s1 amd64 12.3.0-1ubuntu1~22.04 [63.9 kB] Get:7 http://us.archive.ubuntu.com/ubuntu jammy-updates/main amd64 lib32stdc++6 amd64 12.3.0-1ubuntu1~22.04 [740 kB] Get:8 http://us.archive.ubuntu.com/ubuntu jammy-updates/universe amd64 libclang-common-14-dev amd64 1:14.0.0-1ubuntu1.1 [5,975 kB] Get:9 http://us.archive.ubuntu.com/ubuntu jammy-updates/universe amd64 libclang-14-dev amd64 1:14.0.0-1ubuntu1.1 [25.2 MB] Get:10 http://us.archive.ubuntu.com/ubuntu jammy/universe amd64 libclang-dev amd64 1:14.0-55~exp2 [3,138 B] Fetched 44.2 MB in 3s (17.1 MB/s) Selecting previously unselected package libssl-dev:amd64. (Reading database ... 242640 files and directories currently installed.) Preparing to unpack .../0-libssl-dev_3.0.2-0ubuntu1.12_amd64.deb ... Unpacking libssl-dev:amd64 (3.0.2-0ubuntu1.12) ... Selecting previously unselected package libobjc4:amd64. Preparing to unpack .../1-libobjc4_12.3.0-1ubuntu1~22.04_amd64.deb ... Unpacking libobjc4:amd64 (12.3.0-1ubuntu1~22.04) ... Selecting previously unselected package libobjc-11-dev:amd64. Preparing to unpack .../2-libobjc-11-dev_11.4.0-1ubuntu1~22.04_amd64.deb ... Unpacking libobjc-11-dev:amd64 (11.4.0-1ubuntu1~22.04) ... Selecting previously unselected package libclang1-14. Preparing to unpack .../3-libclang1-14_1%3a14.0.0-1ubuntu1.1_amd64.deb ... Unpacking libclang1-14 (1:14.0.0-1ubuntu1.1) ... Selecting previously unselected package libc6-i386. Preparing to unpack .../4-libc6-i386_2.35-0ubuntu3.5_amd64.deb ... Unpacking libc6-i386 (2.35-0ubuntu3.5) ... Selecting previously unselected package lib32gcc-s1. Preparing to unpack .../5-lib32gcc-s1_12.3.0-1ubuntu1~22.04_amd64.deb ... Unpacking lib32gcc-s1 (12.3.0-1ubuntu1~22.04) ... Selecting previously unselected package lib32stdc++6. Preparing to unpack .../6-lib32stdc++6_12.3.0-1ubuntu1~22.04_amd64.deb ... Unpacking lib32stdc++6 (12.3.0-1ubuntu1~22.04) ... Selecting previously unselected package libclang-common-14-dev. Preparing to unpack .../7-libclang-common-14-dev_1%3a14.0.0-1ubuntu1.1_amd64.deb ... Unpacking libclang-common-14-dev (1:14.0.0-1ubuntu1.1) ... Selecting previously unselected package libclang-14-dev. Preparing to unpack .../8-libclang-14-dev_1%3a14.0.0-1ubuntu1.1_amd64.deb ... Unpacking libclang-14-dev (1:14.0.0-1ubuntu1.1) ... Selecting previously unselected package libclang-dev. Preparing to unpack .../9-libclang-dev_1%3a14.0-55~exp2_amd64.deb ... Unpacking libclang-dev (1:14.0-55~exp2) ... Setting up libclang1-14 (1:14.0.0-1ubuntu1.1) ... Setting up libobjc4:amd64 (12.3.0-1ubuntu1~22.04) ... Setting up libssl-dev:amd64 (3.0.2-0ubuntu1.12) ... Setting up libc6-i386 (2.35-0ubuntu3.5) ... Setting up libobjc-11-dev:amd64 (11.4.0-1ubuntu1~22.04) ... Setting up lib32gcc-s1 (12.3.0-1ubuntu1~22.04) ... Setting up lib32stdc++6 (12.3.0-1ubuntu1~22.04) ... Setting up libclang-common-14-dev (1:14.0.0-1ubuntu1.1) ... Setting up libclang-14-dev (1:14.0.0-1ubuntu1.1) ... Setting up libclang-dev (1:14.0-55~exp2) ... Setting up rstudio (2023.12.0+369) ... Processing triggers for libc-bin (2.35-0ubuntu3.5) ... |
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 |
Display detailed console log →
Selecting previously unselected package rstudio. (Reading database ... 239285 files and directories currently installed.) Preparing to unpack rstudio-2023.12.0-369-amd64.deb ... Unpacking rstudio (2023.12.0+369) ... Setting up rstudio (2023.12.0+369) ... Processing triggers for mailcap (3.70+nmu1ubuntu1) ... Processing triggers for gnome-menus (3.36.0-1ubuntu3) ... Processing triggers for desktop-file-utils (0.26-1ubuntu3) ... Processing triggers for hicolor-icon-theme (0.17-2) ... Processing triggers for shared-mime-info (2.1-2) ... |
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.