There are two components to get RStudio to work
First, get R
You can get R from the repositories, but it likely won't be the latest version.
I use Michael Rutter's PPA. The following commands will get the latest version of R installed (updated for R 4.0 and above):
sudo add-apt-repository ppa:marutter/rrutter4.0
sudo apt-get update
sudo apt-get install r-base
Add R's Official repository with these commands (Source):
sudo apt update -qq
sudo apt install --no-install-recommends software-properties-common dirmngr
wget -qO- https://cloud.r-project.org/bin/linux/ubuntu marutter_pubkey.asc | sudo tee -a /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc
sudo add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/"
Note, this repository is available only for LTS versions of Ubuntu.
The official page suggest adding the following PPA for more R packages:
sudo add-apt-repository ppa:c2d4u.team/c2d4u4.0+
sudo apt-get update
sudo apt-get install r-base
Second, install RStudio
Unfortunately, the makers of RStudio do not make their software available via a PPA or in the Ubuntu repository. You have to install it from the deb file which is available on their website.
Go to https://www.rstudio.com/products/rstudio/#Desktop
Click on DOWNLOAD RSTUDIO DESKTOP button.
Look for "RStudio Desktop Open Source License" and click the
DOWNLOAD button below it.
Look under the "All Installer" and find that
says: "Ubuntu 22/Debian 12" (or later if available and based on your Ubuntu version) followed by:
rstudio-<a_bunch_of_numbers>-amd64.deb
This will download the `deb' file. Wait for the download to complete.
Open the terminal and enter:
sudo apt install ./Downloads/rstudio*.deb
Install using software center.
If you run into libgstreamer dependency issues see Install the lastest version of RStudio
You are right, the deb file will not update itself and revisiting the RStudio every now and then to see there are updates is tedious. Inside RStudio Menu > Help > Check for Updates eases the pain somewhat. If you click on this RStudio will check for updates of itself and give you the option to close RStudio and download the new deb file. This will close RStudio and open your default web browser and take you to the RStudio download page in step 3 above.
You can get RStudio to automatically check for updates in Menu > Tools > Global Options...> General Tab> Automatically notify me of updates to RStudio check box.
Bonus Point
As you use R, you will need to install other R packages. Sometimes these are available in the repositories. Say the r package you want it foo then the package in the repositories is called r-cran-foo.
sudo apt-get r-cran-foo
will get the job done. This is the best option as it will keep foo updated. However, this does not always work.
If this does not work you will want to install and/or update R packages from inside RStudio. If you do this, you will find that RStudio would put the new files (including updates) inside in your home directory /home/<user>/R/ .
One way to solve this problem and let RStudio install additional packages in its proper place is to add yourself to the group staff by using the following command in the Ubuntu terminal:
sudo adduser <user> staff
Replace <user> with your username.
After this, you will get the option of installing or updating packages /usr/local/lib/R/ or in /home/<user>/R/ . Then you will be able to choose the former as the default install location.
Source: https://stackoverflow.com/questions/5560139/install-r-package-xml-in-debian-ubuntu
Hope this helps