Is there a function to freely change R versions in Linux?

I'm using R studio
I use several packages, but there are packages that are not compatible with version 4.1.2, so I want to change the version freely.
please tell me the function

Within a script, no, it's not possible to switch freely (because that implies closing R and opening a new session with a different version). But it's possible to have several versions of R installed, and, when starting RStudio, to choose which version to run.

There are instructions here, in short you have to define the environment variable RSTUDIO_WHICH_R.

If you want to always open a given project with an old version (and all other projects with the most recent version), it should work by creating a bash script containing:

RSTUDIO_WHICH_R=/path/to/version/of/R Rstudio /path/to/project.Rproj

(I don't have a Linux install on hand to test)

1 Like

thanks for your reply!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.