Getting started with R
   stats main page

 

 The R statistical software package

R is an open-source package supported by a range of universities, research institutes, corporations and individuals world-wide.

It is extremely flexible and can be used for a wide range of innovative, non-standard methods. We will use this capability to run a simple randomization test.

If all you need - initially at least - is a simple interface to standard data analysis techniques with pull-down menus and dialogue boxes, you can use the "R commander" package.


Installing R and using R for simple tasks

Click here for information and links for installing R.

"oRientation - starting off with R" is a 'Lab guide' in .pdf format which you can print out and keep next to the computer as you work through it. It includes –

  • hints on setting up a new project in R
  • simple arithmetic
  • basic arithmetic and statistical functions built in to R, including sum(), mean() and sd()
  • using vectors, including data types, named vectors, and indexing
  • data frames and factors
  • the use of scripts in R : the example script is here
  • tidying up and saving your work, and closing R at the end of session.

R comes with several manuals including 'An Introduction to R'. You can access this within R by selecting 'Help > Manuals (in PDF) > In Introduction to R' from the pull-down menus. A good place to begin is "Appendix A - A sample session".


The following files are scripts. An R script is simply a text file with the extension ".R" which contains the same commands that you would type directly into the R Console, together with comments preceded by the "#" symbol.

To use them, download them to your hard disk and open them within R using 'File > Open script...'. Execute lines in the script by simply placing the cursor in the line to execute and press Ctrl-R (or you can choose "Run line or selection" from the Edit menu or the right-click context menu).

Jackals_script.R: works thro a randomization test to compare the lengths of male vs female golden jackal jaws in a museum collection.

Squirrels_script.R: investigates population parameters and sample statistics (mean, standard deviation and degrees of freedom) using a simulation population of 'squirrels'; it accompanies the 'Sampling squirrels' web page .


The next one is also a script, but it's used to load customized functions into your R session. Download the script file to your hard disk. Then open R, select 'File > Source R code...'  from the pull-down menus, and navigate to the script file (or just drag-and-drop the file into R's Console window).

Interact_fun.R: Loads a selection of functions providing interactive demonstrations of statistical concepts. A pull-down menu with the 'Interact' functions should appear when you source the file. The Interact manual is a PDF file explaining what it does.

wcsmalaysia.org home

Page updated 8 May 2009 by Mike Meredith