Accordingly, you set PATH. There are tools / libraries that do this for you (usually in university environments with multiple versions of things in /usr/local/ or /opt .
Here is a simple ad-hoc version:
edd@max :~$ which R
A change in a file can be done using a script or in different ways. The key is that by prefacing the PATH with the one you need, you will get the first version.
source share