library(oce)
t.start <- as.POSIXct("2008-01-01", tz="UTC")
t <- seq(t.start, length.out=48, by="30 min")
y <- sin(as.numeric(t - t.start) * 2 * pi / (12 * 3600))
oce.plot.ts(t, y, type='l', xaxs='i')
## weather plot
library(oce)
weatherplot <- function(stationID=6358, time=as.POSIXlt(Sys.Date()), title)
{
## The default stationID is Halifax, NS, Canada
site <- "http://www.climate.weatheroffice.gc.ca/climateData/bulkdata_e.html"
time <- as.POSIXlt(time)
f <- paste(site,
"?StationID=", stationID,
"&Year=", time$year+1900,
"&Month=", time$mon+1,
"&Day=", time$mday,
"&format=csv&type=hly", sep="")
d <- read.csv(f, skip=15, header=TRUE)
oce.plot.ts(as.POSIXct(d$Date.Time), d$Stn.Press..kPa., type='l',
ylab="Pressure [dbar]", cex=2/3,
main=if(missing(title)) stationID else title)
}
weatherplot(6358, time=as.POSIXlt(Sys.Date()), title="Halifax NS")
Run the code above in your browser using DataLab