R is freely available for Windows and other operating systems and once installed is relatively easy to use. I highly recommend installing the latest R version for Windows (or Windows emulator in Mac). I also recommend running R from within the R Studio environment. Here are instructions based on these recommendations.
Please refer to the Software page for a complete list of software, which will be periodically updated. The list (and links below) provide weblinks to files that you need to download to your computer hard drive and install. Typically you simply click on the link, or right click and "save to". Please download and install software in the the following order:
Then download and install the remaining programs (order not important)
Finally, save the following file to a convenient location (that you'll remember, we'll need to come back and get it in a bit)
R can be opened and run directly from the R console by simply clicking on the R icon (in Windows). The R console will open:
Commands can be typed directly at the prompt > , or read from script files that are created by R (in this or a previous session). There will be more details on running from command line and creating and running script files later, but for now I'll illustrate with a small example. From the main menu, select File/New script. This will open up an editor in which R commands can be saved (existing files are opened by Open Script). The Save or Save as commands can be used to save a new or modified script file.
R commands can be either entered directly in the console by typing after the > , or read from the script file, for example
Running R from Tinn-R
Tinn-R provides a alternative Graphical User Interface (GUI) for R that some people like. I don't-- I find it a bit ¨busy¨. I will not describe Tinn-R here, but if you're interested check out the information on the SourceForge website.
Using R in R studio
While it is certainly possible to run R from the standard R console (simply by clicking on the R icon in Windows), or from Tinn-R as above, I have found that R Studio provides a very nice environment for a number of reasons:
I will try to give you an idea of the R studio environment by a simple demo.
The display (for now) is divided into 3 major parts.
Over the top of these 3 windows is a menu bar that we can use to control certain operations in R, such as telling R where files are and running code.
We'll use R studio to perform a simple but important bit of housework: installing the R packages (libraries of programs) needed to do our analyses. Go to the menu bar and select "Session\Set working directory"
then "Choose directory"
Navigate to the folder where you put install.R and select this as the working directory. It may appear as if there are no files in the folder and that is okay! The console should confirm the directory location; also the content of that directory including install.R should be displayed in the "Files" window.
You can open the file install.R in either of 2 ways:
By either approach you should see something like this:
The code can be executed (run) a couple of different ways (at least). For a tiny program like this we can run it line by line by putting the cursor in front of a line and selecting "Run" at the top of the source window.
Alternatively, we can run all the lines at once from the main menu
You need to be connected to the internet. R will look for these programs on the CRAN site from which you downloaded R, or if you are on a different computer may ask you to select a site (they are all the same, pick one geographically close so c doesn't slow you down).
There are many more things you can do out of the R Studio environment, but these are some essentials. By the way, note that if you open a file in the File windows with certain special extensions you will get a "Viewer" display, e.g., if you open a graphics file (.jpg or similar extension) the file will display in a graphics viewer.
Next: Basics of the R language