This repository contains a Shell script (setup.sh
) to set up an R environment with necessary dependencies and configurations for geocomputation on an Ubuntu system HPC.
- Ubuntu: The script is designed for Ubuntu systems. Ensure you are running a compatible version.
- sudo privileges: You need administrative privileges to install packages and modify system settings.
You can download the setup.sh
script directly from GitHub using the following command:
wget https://raw.githubusercontent.com/ai4city-hkust/RSpatialHPC/main/setup.sh
This will download the script to your current directory.
Before running the script, you need to make it executable. Run the following command:
chmod +x setup.sh
This grants execution permissions to the script.
Execute the script with the following command:
./setup.sh
The script will:
- Prompt you for your
sudo
password to cache it for the session. - Install necessary system dependencies.
- Set up R and configure the R package installation path.
- Install required R packages.
- Optionally install RStudio Server (if you choose to).
The script is interactive and will guide you through the process. For example:
- You will be asked if you want to install RStudio Server.
- The script will automatically configure the R library paths based on your system.
After the script completes, you can verify the setup by starting R and checking the library paths:
R
Inside the R console, run:
.libPaths()
This will display the configured library paths, ensuring the setup was successful.
The script performs the following tasks:
- System Information: Displays Ubuntu version and CPU information.
- System Updates: Updates the package indices and installs necessary helper packages.
- R Installation: Adds the CRAN repository and installs base R.
- R Dependencies: Installs system dependencies required for R packages.
- RStudio Server (Optional): Installs RStudio Server if requested.
- R Library Path Configuration: Sets up a custom R library path (
~/pkgR
or~/pkgRUserLocal
) and writes it to~/.Rprofile
for persistence. - R Package Installation: Installs essential R packages like
tidyverse
,sf
,terra
, and others.
- RStudio Server: Installation of RStudio Server is optional. If you choose not to install it, you can still use R from the terminal or install RStudio Desktop separately.
- Custom Library Path: The script checks if
~/pkgR
exists. If it does, it uses~/pkgRUserLocal
as the R library path; otherwise, it uses~/pkgR
. - Persistent Configuration: The R library path is written to
~/.Rprofile
, ensuring it is applied every time R starts.
- Permission Issues: Ensure you have
sudo
privileges to run the script. - Network Issues: If the script fails to download packages or keys, check your internet connection.
- R Path Issues: If
.libPaths()
does not show the expected paths, manually check the~/.Rprofile
file for correct configuration.