## call in circular package require(circular) makeweather <- function(weather.df) { ## subset to obtain variables of interest weather.df <- subset(weather.df, select = c(Year, Month, Day, Time, Wind.Dir..10.s.deg., Wind.Spd..km.h.)) # adjust variable names names(weather.df) <- c("year", "month", "day", "time", "wdir", "wspd") # convert to posix time - dates are in LST weather.df$timestamp <- with(weather.df, as.POSIXct(strptime(paste(year, month, day, time), format = c("%Y %m %d %H:%M")) + 4*60*60), tz = "GMT") # set tz = GMT so that command will not use computer time zone # adjust wind direction weather.df$wdir <- weather.df$wdir*10 weather.df$wdir <- as.circular(weather.df$wdir, units = "degrees", type = "directions", template = "geographics", rotation = "clock", zero = 0, modulo = "asis") # adjust wind speed weather.df$wspd <- weather.df$wspd * 1000/3600 ## convert to numeric for interpolation in addweather.R weather.df$timestamp <- as.numeric(weather.df$timestamp) return(weather.df) }