Working with R projects often requires using multiple versions of R, especially while troubleshooting, testing, or maintaining legacy code. This article focuses on changing the R version associated with a specific R data file in Windows 10.
Associating R Versions with File Extensions
In Windows 10, you can associate file extensions with specific applications, such as R versions. To change the R version associated with an R data file (.rda or .RData), you must modify the file association settings.
Step 1: Open the File Explorer Options
Press Windows key + E to open File Explorer, then click the "View" tab and check "Hidden items" to display hidden files and folders.
Step 2: Locate the R Versions Installation Directory
Typically, R versions are installed under C:\Program Files or C:\Program Files x86. For instance, R-3.6.3 might be located at C:\Program Files\R\R-3.6.3.
Step 3: Change File Association Settings
Press Windows key + R and type regedit to open the Registry Editor. Navigate to the following key:
Computer\HKEY\_CLASSES\_ROOT\.rda
In this key, you will find a value like "R.rda._python.file". Double-click the "(Default)" string value under it.
\HKEY_CLASSES_ROOT\.rda\R.rda._python.file(Default)
Modify its value by replacing the existing path with the new R version installation directory, such as:
C:\Program Files\R\R-3.6.3\bin\i386\r.exe
By associating the .rda extension with the R version executable, you can ensure the correct R version is used when opening or executing R data files.
Changing R Version Associated with RStudio
If you are using RStudio as your primary IDE, you might need to change the R version associated with it.
Step 1: Open the RStudio Options
Launch RStudio, then go to Tools > Global Options, or press Ctrl + Alt + Shift + K on your keyboard.
Step 2: Change R Version
Under the "General" tab, locate the "R Version" dropdown menu. Select the desired R version to use with RStudio.
- Associate R extensions with specific R version executables in the Windows 10 Registry Editor.
- Change the R version associated with RStudio in the IDE's Global Options panel.