First, I want to thank Marcus and Todd for creating this awesome tool. SWMPr is so powerful, intuitive and easy to use. It's great for getting started looking at SWMP data.
I am struggling to extract individual seasons from SWMPr data frames. While I'm proficient in MATLAB, bash and such, R is new to me so I apologize if this is a novice question. I've taken two approaches, neither has worked.
The first approach is creating month, day and year arrays and then attaching them to the original SWMPr data frame.
#Grab a subset of the data, in this case the date-time stamp
ph <- subset(dat, select = 'ph')
dts = ph[['datetimestamp']]
datearray <- as.Date(dts, "%Y-%m-%D %H")
#Extract numeral date/time info from R date class
mm=as.numeric(format(dts, "%m"))
yyyy=as.numeric(format(dts, "%Y"))
dd=as.numeric(format(dts, "%d"))
#add month and year to swmp data frame for easy subsetting
dat$mm <- c(mm)
dat$yyyy <- c(yyyy)
dat$dd <- c(dd)
#create a seasonal subset of data, i.e. JFM
params <- c('temp','sal','ph')
winter_dat = subset(dat, mm<4, select = params)
This approach produces an error message of: "Error in as.POSIXct.default(subset, format = "%Y-%m-%d %H:%M", tz = timezone) :
do not know how to convert 'subset' to class “POSIXct”"
My second approach is to use the SWMPr aggregate function to produce quarterly globs, and then target the globs.
#Produce Seasonal Aggregates
q_ph=aggregate(dat, 'quarters', params = c('ph'), aggs_out = TRUE)
q_ph_jja <- subset(q_ph, format(q_ph$datetimestamp,'%m') %in% c('01','02','03'))
This produces an identical error. I think that this is occurring because the subset function is now 'pointing' to the SWMPr subset function, which is not built to handle this sort of approach. What then is the best way to grab individual seasons of data from a SWMP data frame?
I am interested in doing a comprehensive EDA on the data, so prefer keeping the raw data in tact and then calling R functions to assess spread, center, etc.
Thanks for both the great tool and for any thoughts on seasonal extractions!