Installing R and other software
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.
Getting the software
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 script to install required packages
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), I have found that R Studio provide a very nice environment for a number of reasons:
It provides a convenient way to simultaneous view R commands, interactive results, and "objects" (data, functions, etc.)
It makes it easy to control the programming environment, such as
Setting the local or working directory (where R knows to look for your data and write output)
Selectively running R commands
Installing new packages as needed
I will try to give you an idea of the R studio environment by a simple demo.
First, set up a directory (folder) on your computer and save or copy the R script to install required packages
Then, click on the R studio icon; this will automatically open R (and give you an error if R is not installed or you have an incompatible version). Hopefully, you will see something like this:
The display (for now) is divided into 3 major parts.
The Console, which for now contains information about he R version. We can also enter R interactive commands here and see the results immediately displayed
The Environment/history window, which displays information about R objects (more on these in a minute), allows viewing of dataframes (ditto), and keeps track of what's been done (history)
The Files/plots/ packages window lets us view the contents of the hard drive, display and save graphics, control R packages, get help, and other tasks.
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. 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:
Go to the files window and click on the file name. Since the file has an R extension it will automatically open in a new Source (code) window
Select "File\Open File" from the main menu. By default the contents of the working directory are displayed; click in install.R
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 the internet. R will look for these programs on the CRAN site from which downloaded R, or if you are an 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.