Book contents
- Frontmatter
- Contents
- Preface
- 1 Random variables
- 2 Statistical models and inference
- 3 R
- 4 Theory of maximum likelihood estimation
- 5 Numerical maximum likelihood estimation
- 6 Bayesian computation
- 7 Linear models
- Appendix A Some distributions
- Appendix B Matrix computation
- Appendix C Random number generation
- References
- Index
3 - R
Published online by Cambridge University Press: 05 April 2015
- Frontmatter
- Contents
- Preface
- 1 Random variables
- 2 Statistical models and inference
- 3 R
- 4 Theory of maximum likelihood estimation
- 5 Numerical maximum likelihood estimation
- 6 Bayesian computation
- 7 Linear models
- Appendix A Some distributions
- Appendix B Matrix computation
- Appendix C Random number generation
- References
- Index
Summary
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.
- Type
- Chapter
- Information
- Core Statistics , pp. 49 - 78Publisher: Cambridge University PressPrint publication year: 2015