Simple script for installing R and R Studio on:

MacOS:

# Install Xcode Command Line Tools
xcode-select --install
# Install Homebrew, the package manager for macOS
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Install R
brew install r
# Download and install R Studio
brew install --cask rstudio
echo "Installation completed."

Linux:

# Update the package list
sudo apt update
# Install R
sudo apt install r-base
# Install dependencies for R Studio
sudo apt install gdebi-core
# Download the latest version of R Studio
wget https://download1.rstudio.org/desktop/bionic/amd64/rstudio-1.4.1106-amd64.deb
# Install R Studio using gdebi
sudo gdebi rstudio-1.4.1106-amd64.deb
# Remove the .deb file after installation
rm rstudio-1.4.1106-amd64.deb
echo "Installation completed."

Windows:

# Download and install R
Invoke-WebRequest "https://cran.r-project.org/bin/windows/base/R-4.1.2-win.exe" -OutFile "$env:TEMP\R-4.1.2-win.exe"
Start-Process -FilePath "$env:TEMP\R-4.1.2-win.exe" -ArgumentList "/SILENT" -Wait
Remove-Item "$env:TEMP\R-4.1.2-win.exe"

# Download and install R Studio
Invoke-WebRequest "https://download1.rstudio.org/desktop/Windows/RStudio-2021.09.1%2B372.exe" -OutFile "$env:TEMP\RStudio-2021.09.1+372.exe"
Start-Process -FilePath "$env:TEMP\RStudio-2021.09.1+372.exe" -ArgumentList "/S" -Wait
Remove-Item "$env:TEMP\RStudio-2021.09.1+372.exe"

Write-Host "Installation completed."

My site is free of ads and trackers. Was this post helpful to you? Why not BuyMeACoffee


Reference:

  1. MY $500M MARS ROVER MISTAKE: A FAILURE STORY