Notice and Reasoning:

Previous updates to the "RStudio and R" application deployment in UKSeRP caused an issue within the existing environments for users. Following an update, the R directory becomes that of the updated version, in cases breaking environments due to package versions, or missing packages.

The way in which is will be alleviated is by applying a modified R_LIBS_USER value, currently this points to P:\%USERNAME%\AppData\Roaming\R\Library the new path will be P:\%USERNAME%\AppData\Roaming\R\%V\Library. The %V will create the relevant R version directory.

This change is to address the issue of users needing to reset their environment with the latest packages for the new R version provided. Going forward, this will have a positive effect of segregating R environments. This will still impact users during the first deployment of the change, but users will be able to select different R versions for their work and ability to return to older environments.


Please do the following if you used RStudio prior to Friday 24th May 2024.

Step 1

On the desktop, locate the "My Folder (P)" and open.

Step 2

Navigate to the folder, AppData\Roaming\R

Step 3

If you have already opened RStudio, you may see a 4.1.3 folder present under the folder R. You will need to move your previous library into this folder.

Click and drag the Library folder into the 4.1.3 folder. (You may select skip or replace for file existing files).

If you have not yet opened RStudio, you will need to create the 4.1.3 folder.

Simply Right click in the empty white space, create new folder, right click the folder and re-name this "4.1.3" and then select the Library folder. Cut and Paste into the 4.1.3 folder, or alternatively drag and drop (as above).


Specifying the version of R within RStudio.

Should you wish to change the version of R being used by RStudio. Ensure that if your library is setup for 4.1.3, you set R to 4.1.3 with either of the following methods, else pick the relevant option to your library.

Change R within RStudio

  1. Go to Tools > Global options
  2. Click 'Change...' under R version
  3. Click the 'Choose a specific version of R' option
  4. Select '[64-bit] C:/Program Files/R/R-4.1.3'
  5. Click Okay
  6. Click Apply

Change R on launch of RStudio

Hold the CTRL key and double click the RStudio launcher, as shown below:

Doing this will change the folder in which RStudio loads your library, as shown above, if you select 4.1.3, the library path will be P:\%USERNAME%\AppData\Roaming\R\4.1.3\Library


Additional steps/notes:

I have an IM004 error.

This is due to an environment variable not being set. You may check this within R by entering the following into the Console:

Sys.getenv("DB2CODEPAGE")

If this is coming back blank then you need to make sure it's being set:

Sys.setenv("DB2CODEPAGE" = 1208)

or run "DEM Environment Refresh", found on the desktop.


How can I tell which version of R I am using?

When loading RStudio, you will see at the top of the console:


If holding CTRL on your keyboard does not load the "Choose R Installation" Please search for the On-Screen Keyboard within Windows start menu, and use this. Pressing the Windows Key on your keyboard, or clicking the menu on the Desktop, type "On-Screen Keyboard"


Related issues, but not strictly required:

"Unable to install packages" This is likely due to the proxy not being set, to correct this add the following into the R Console:

Sys.setenv(http_proxy="http://proxy:8080)

Sys.setenv(https_proxy="http://proxy:8080)



RStudio error with package and R version

"I'm having trouble installing and loading packages in R.
When I try to load previously installed packages I get this error message:

library(PACKAGENAME)
Error: package or namespace load failed for ‘PACKAGENAME’:
package ‘PACKAGENAME’ was installed before R 4.0.0: please re-install it
In addition: warning message:
package 'PACKAGENAME' was built under R version 4.0.3

Package has been, reinstalled but to no avail. Same error is produced when calling package."

To correct this error, run the following command:

update.packages(checkBuilt = TRUE, ask = FALSE)




  • No labels