Filter Southern Oscillation Index

First of all we download the latest SOI data from Longpaddock. It is in a fixed-width format. Convert the dates to a sensible format, and create a filtered smooth data series to go with it.

library(signal)
## Loading required package: MASS
## Attaching package: 'signal'
## The following object(s) are masked from 'package:stats':
## 
## filter, poly

month.soi = read.fwf("http://www.longpaddock.qld.gov.au/seasonalclimateoutlook/southernoscillationindex/soidatafiles/MonthlySOI1933-1992Base.txt", 
    widths = c(4, 5, 6), skip = 1, colClasses = "numeric", col.names = c("year", 
        "month", "soi"))
month.soi$c_date = as.Date(paste(month.soi$year, "-", formatC(month.soi$month, 
    digits = 0, width = 2, format = "f", flag = "0"), "-15", sep = ""), format = "%Y-%m-%d")
month.soi$sm_soi = sgolayfilt(month.soi$soi, p = 5, n = 15)

Now we plot the raw data with the smooth on top.


plot(soi ~ c_date, data = month.soi, type = "l")
lines(sm_soi ~ c_date, col = "red", data = month.soi, lwd = 2)
abline(h = 0)

plot of chunk unnamed-chunk-2