Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Introduction
R.M. Ripley
Department of Statistics
University of Oxford
2012/13
What is R?
What can you do using R?
Statistical analysis
Summaries: mean, variance, density
Linear modelling (and Generalised Linear and Non-Linear)
Many more exotic methods
What is R?
What can you do using R?
Statistical analysis
Summaries: mean, variance, density
Linear modelling (and Generalised Linear and Non-Linear)
Many more exotic methods
Graphical display
Predefined plots for some models
Flexible, powerful options
Save to image files in various formats
Write new functions
Make a change to an existing function
Create new functions tailored to your exact needs
Contribute a new package
Graphical display
Predefined plots for some models
Flexible, powerful options
Save to image files in various formats
Write new functions
Make a change to an existing function
Create new functions tailored to your exact needs
Contribute a new package
Graphical display
Predefined plots for some models
Flexible, powerful options
Save to image files in various formats
Write new functions
Make a change to an existing function
Create new functions tailored to your exact needs
Contribute a new package
Graphical display
Predefined plots for some models
Flexible, powerful options
Save to image files in various formats
Write new functions
Make a change to an existing function
Create new functions tailored to your exact needs
Contribute a new package
To save any
changes, click Save
and accept the
default file name.
Then quit using q()
and restart R.
To get multiple
windows either
add --sdi after
the target in the
properties of the
short cut
or choose sdi
via the Edit/Gui
preferences
menu option
Exiting from R
The Esc key will terminate the current operation (Ctrl-C on Linux)
Help
Type ?help
A brief demo
Type 2 + 3 <return>
A brief demo
Type 2 + 3 <return>
A brief demo
Type 2 + 3 <return>
Introductory session
All objects are held in memory and not saved unless you request
this.
When you quit (q()) R will ask if you want to save your work.
If you say yes, R writes a file called .RData in the current folder.
If you use the Mac R.app, automatic loading and saving may work
differently.
It is a good idea to save data that you have spent a lot of time on,
or model fits that take a lot of time. Much better to save the
workspace yourself with a “real” name than use the default saving
system.
Working with R
It is a good idea to store commands in one of
1 script window
2 emacs editor
3 other external editor e.g. Tinn-R, WinEdt
You will be able to use all the characters in your language as part
of variable names. But not very portable!
e.g. library("car")
Exercises 1
Explore a package
Install and load the package ‘car’
Read about the dataset Davis.
Use the function scatterplot to plot reported weight (y) against
weight (x) for the subjects in this dataset.
What do the dotted lines represent?
Add a suitable title to the graph.
Random numbers
Generate a sample of size 100 from a Poisson Distribution with
mean 4.
Calculate the standard deviation.