# 8-6 Applying functions to data frame

# Use the CleanResults data

# The data is held in a file called CleanResults.csv
# This is within the SP08 folder of the current working directory
# The file contains headers

# Load file

cleanresults<-read.csv("SP08/CleanResults.csv", header=TRUE)

# Display results

cleanresults

# Use sapply to calculate the means for all columns

sapply(results, mean)  # Where the mean cannot be calculated,
                       # NA is returned.

# Use sapply to calculate the mean for column 3 (CW1)

sapply(results[3], mean)
