R and Rstudio may be slow. This is because our laptops install to the network by default. When you intend to work with these programs regularly, you will be unhappy with that situation.
Here's a step-by step tutorial to installing R
the right way. Administrator rights required.
-
Try to uninstall
R
andRStudio
. This may be impossible, but try anyway. -
Download
R
. When the.exe
is downloaded, right-click it and "run as administrator". Make sure it installs on yourC:\
drive. -
Download
RStudio
. Again, right-click and "run as administrator" to install it on yourC:\
drive. -
Go to the installed rstudio.exe (for example by pressing the windows key and typing rstudio). Right-click it > properties > compatibility > check "Run this program as an administrator" > apply. This is required to install packages on the
C:\
drive. -
Make a folder on your
C:\
drive where you wantR
andRStudio
to go by default. For exampleC:\Users\<username>\r_dir
. -
Press the windows key, type "environment" and open "Edit the system environment variables".
-
Click on "Environment Variables..." this opens another dialog. Here we will add 2 entries in the User variables and in the system variables. For each of these, click "New"
- Variable name:
R_HOME
; Variable value:C:\Program Files\R\R-[x.x.x]
(the folder you installedR
to) - Variable name:
R_USER
; Variable value:C:\Users\<username>\r_dir
(the folder you just made)
Environment variables done!
- Variable name:
-
Open the RStudio version you just installed. It will ask for administrator permission. Give this permission.
-
Open the file
C:\Program Files\R\R-[x.x.x]\etc\Rprofile.site
. Add the following line:.libPaths("C:\\Program Files\\R\\R-[x.x.x]\\library")
NB: replace [x.x.x] with your
R
version, for example3.4.3
. Close the file. -
Restart
RStudio
. Run the following 2 commands to check whether it worked:.libPaths()
This should return the library path on the local disk only.path.expand("~")
This should point to theR_USER
path on yourC:\
drive.
-
Install your packages and rejoice!
Leave a comment if you have any questions.
If I install a new version of R, do I only have to redo stop 8? Or do I have to do anything else again as well?