# NOT RUN {
# Calculate within year deviance in temperature from the MassClimate dataset.
data(MassClimate)
#Calculate year column
library(lubridate)
MassClimate$Year <- year(as.Date(MassClimate$Date, format = "%d/%m/%Y"))
#Calculate within year deviance of temperature
within_yr_dev <- wgdev(MassClimate$Temp, MassClimate$Year)
#Add this variable to the original dataset
MassClimate$Within_yr_dev <- within_yr_dev
# }
Run the code above in your browser using DataLab