brew install r 21 R on macOS
You can download R for macOS from the R website. However, I strongly recommend installing R via the command line package manager Homebrew. First, some R packages require you to install additional libraries on macOS anyway. If an installation of an R package fails on macOS, it is likely that you are missing a software library. With Homebrew you can install these libraries easily (e.g., GDAL for the R package sf). Furthermore, updating R to a new version is just a matter of calling brew update (updates the Homebrew catalog) and brew upgrade (updates outdated packages). You can remove R from your system with brew remove r.
Check out the Homebrew website for installation instructions. It is easy!
Install R with Homebrew in your macOS terminal:
Install GDAL and PROJ required for the R packages terra and sf:
brew install gdal proj udunits