Problem sheet 1 -- Getting started with R

Reading data

Using a text editor, generate a datafile "test.dat" with entries
1 2
2 5
3 7
4 10
5 6
6 19
Read this file into R.
  • Plot the variable in the first column vs. the variable in the second column using points as symbols to indicate datapoints.
  • Connect the first three points in the dataset by a green line.

    Data for the water levels of Lake Huron

    Import the dataset on water levels for lake Huron into R (use "data (LakeHuron)" to import this dataset from R's example database).
  • Generate a graph that shows the dependence of water levels of lake Huron on time. Use points connected by lines to do this.
  • Plot a histogram of water levels of Lake Huron. Change the x-scales to the range 570 to 590 and change the y-axis to showing the probability instead of the frequency. Change the labels of the axes and the title of the plot.
  • Use R to generate an estimate of the underlying probability density function for the distribution of water levels in lake Huron and add R's estimate as a red line to the graph.

    Data on chicken experiments

    Experiments have been carried out to determine the influence of various food types on the resulting weight of chicken. Download the datafile ( wts.data ) and import the data into R.
  • Analyse the dependence of chicken weight on food type by determining the meadian and mean of chicken weight for each food type.
  • Generate a boxplot of chicken weight vs. food type and save the output as a pdf file.
  • Generate a plot that plots experiment number (first row) vs. chicken weight. Indicate the data points that correspond to under-weight chicken (<180 units of weight) by red dots.

    Data on US women

    Import the dataset "women" on the heigh-weight relationship of American women from the R database (use the command "data(women)").
  • Generate an R plot that illustrates this relationship.
  • Fit linear and higher order polynomial models to the data and illustrate the best fits as coloured curves in the plot.
  • Using Akaike's information criterion, determine which order of the polynomial gives the best fit.