R and RStudio
Configurations of RStudio on Windows
Using R and RStudio on Windows in our domain can throw up a few unexpected errors, this page is intended to help work around the few issues that we have seen.
...
In the Console area of RStudio copy and paste the following two lines then press Enter;
|
A new file will open in the File area, in the top left quadrant of RStudio. In that File area paste the following lines and then save the file, following the format shown below;
|
Save this file. Note that in the example above we are including a group drive mounted as V:, this may or may not be necessary or desirable for all use cases. Also note that if you are using a laptop then rather than referencing the U: drive it might be better to use e.g. C:/Users/###/Documents/R/win-library/3.6. This is because a laptop may not always be connected to your backed up network drive usually found at U:
...
Now close and reopen RStudio, when you type getwd() into the console it should return;
|
And typing;
|
should return something similar to;
|
the second entry may be a little different, depending on the group drive folder you are using.
When you install packages, ensure that you are selecting either your personal (U:/My Documents), or a shared repository (e.g. V:/Rlib_shared) as the destination;
|
RBuildTools
If using the C++ toolchain (for packages similar to rstan or brms) then you will also need to do the following. If you are unsure whether this is applicable, then run these commands anyway, it simply creates a text file which is used by the C++ toolchain and will be ignored of not required.
In the Console area of RStudio copy and paste the following three lines then press Enter;
|
A new file will open in the File area, in the top left quadrant or RStudio. In the File area paste the following 3 lines and then save the file
|
Now run the following command in the Console;
|
This will either return TRUE or FALSE, in the latter case RStudio will offer to install the build tools. Note that you will need to be an Administrator on the computer to install the build tools, but if already installed you do not need to be an admin to use them. You can also install the build tools from software.medschl.cam.ac.uk
When using the library you may wish to set options in order that rstan use all the available processor cores and save the compiled Stan program to disk;
|
to return the number of cores in use run;
|
these options are described in more detail at;
https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started
RStan
Now in the bottom left window of RStudio run the following commands;
|
then run;
|
this should prompt to download and install the C++ toolchain to C:\RBuildTools, just accept any defaults offered and let it install
...
Having got to this point now please run
|
to load the library, this should return something similar to;
|
In RStudio select Fine > New File > Text then paste the following into the top left window;
|
Save this file as U:\My Documents\8schools.stan. Now in the lower left R prompt paste the following and press Enter;
|
finally run the following command in the lower left R window;
|
the expected behavior is that it will appear that nothing is happening for a minute or two then text similar to the following wil indicate success;
|
RAM & CPU usage
memory.limit() and memory.size() will report RAM limit and in use sizes respectively, in MB
...