Exercises Basics
John Bastiaansen
Exercises : Introduction
- Before you start: You may want to type all your exercises in the R script window such that you can save your work.
- Open a script window from the File menu
- Type getwd() and then use
CTRL-Enter to run the command
- Close (and save) the script to a location that you can take home such as a usb drive
- Reopen the script.
- Familiarize yourself with the help in R and the R website.
- Look for help on the functions
data.frame, dim, and mean.
- Go to the R project website (note the manuals pages)
- Go to the CRAN site (what is the most current version of R ?)
- Get a list of all the functions in R that contain the text “t test” or another word of your interest.
- For information on how to do this, read the help for the function
help.search.
Exercises : Basics-1
- Packages
- Use the instruction in the course notes to install a new package
pedigree or any other package that you might like (see CRAN for a list of packages)
- Vector
- Create a
vector aa which contains 8 numbers
- Copy the first 3 elements from aa into another vector aaa
- Check the length and class of the resulting object
- Use aa to make another
vector bb which contains squared values of aa
- Calculate the mean of bb.
Exercises : Basics-2
- Matrix
- Create a 10x10
matrix my.matrix which contains numbers 1 to 100.
- Calculate the mean of the matrix
- Calculate the mean of the first column of my.matrix
- Calculate the mean of the third row of my.matrix