# Below are a few R command lines to get you started. # Note: The # symbol means "comment". # First download the file temp.txt from the following address: # http://www.met.rdg.ac.uk/cag/courses/Stats/Data/temp.txt # # This file contains daily temperatures measured at the University # of Reading during 2003. The file has three columns, each containing # 365 daily temperature measurements recorded in degrees Celsius at # the University of Reading meteorology station between 1 January and # 31 December 2003. The three columns contain daily mean, minimum and # maximum temperatures, respectively. Missing values are given the value `NA'. # Read file temp.txt and stores the content in variable name temp temp <- read.table("temp.txt",header=T) # Look at the first 5 lines of the file temp[1:5,] # Plot mean temperature time series plot(temp[,1],type='l') # Produce boxplot and histogram of daily mean temp (firt column of temp) boxplot(temp[,1]) hist(temp[,1]) # Plot histogram with normal density superinposed x<-seq(-5,30,0.1) y<-dnorm(x,mean(temp[,1], na.rm = TRUE),sd(temp[,1], na.rm = TRUE)) hist(temp[,1], freq=FALSE, ylim=c(0,0.08)) # freq=FALSE plots density instead of frequency lines(x,y) # Compute mean, standard deviation, median, IQR, quartiles and range # of daily mean temperature mean(temp[,1], na.rm = TRUE) # na.rm = TRUE is used to remove NA from computation of the mean sd(temp[,1], na.rm = TRUE) median(temp[,1], na.rm= TRUE) IQR(temp[,1], na.rm= TRUE) quantile(temp[,1], na.rm= TRUE) range(temp[,1], na.rm= TRUE) # returns min and max of temp[,1] # help about quantile() function help(quantile) # For more help either go to www.r-project.org # or type help.start() when in R # To exit do this and then say yes to save workspace quit()