Published online by Cambridge University Press: 05 April 2015
Statistical analysis of interesting datasets is conducted using computers. Various specialised computer programmes are available to facilitate statistical work. For using general statistical theory directly with custom-built models, R is probably the most usefully flexible of such programmes.
R (R Core Team, 2012) is a progamming language and environment designed for statistical analysis. It is free (see http://cran.r-project.org to obtain a copy) and is written and maintained by a community of statisticians. A major design feature is extendibility. R makes it very straightforward to code up statistical methods in a way that is easy to distribute and for others to use. The first place to look for information on getting started with R is http://cran.r-project.org/manuals.html. I will assume that you have installed R, can start it to obtain a command console, and have at least discovered the function q() for quitting R.
The following web resources provide excellent guides to the R language at different levels.
• http://cran.r-project.org/doc/contrib/Short-refcard.pdf is a four page summary of key functions and functionality.
• http://cran.r-project.org/doc/contrib/R_language.pdf is a very concise introduction to and reference for the structure of the language.
• http://cran.r-project.org/doc/manuals/R-lang.html is the main reference manual for the language.
A huge amount of statistical functionality is built into R and its extension packages, but the aim of this chapter is simply to give a brief overview of R as a statistical programming language.
Basic structure of R
When you start R (interactively) two important things are created: a command prompt at which to type commands telling R what to do, and an environment, known interchangeably as the ‘global environment’ or ‘user workspace’ to hold the objects created by your commands. Unlike the command prompt, you do not see the global environment directly, but it is there as an extendible chunk of computer memory for holding your data, commands and other objects.
Generically in R an ‘environment’ consists of two things. The first, known in R jargon as a frame, is a set of symbols used to refer to objects, along with the data defining those objects.
To save this book to your Kindle, first ensure [email protected] is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.
Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.
Find out more about the Kindle Personal Document Service.
To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Dropbox.
To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Google Drive.