Define periods, temporal categories such as 'Quarter', 'Month' or some custom defintion.
Arguments
- processData
TemporalDefinition
as returned from this function.- TemporalCategory
type of temporal category: 'Quarter', 'Month' or 'Custom', defaults to 'Quarter'
- CustomPeriods
provide if temporalCategory is 'Custom', vector of strings formatted as DD-MM or DD-MM-YYYY, giving the start date of each temporal category. See 'details'
- UseProcessData
If TRUE, bypasses execution of function and returns existing 'processData'
Value
Temporal Categories, see: TemporalDefinition
.
Details
Periods define an association between dates and a categorical variable definition, such as 'Month', 'Quarter' or some custom definition.
Periods may be seasonal, which means that dates are associated with the categories based on day and month only. This distinction does not matter if all data is from the same year. The 'TemporalCategory'-options 'Quarter' and 'Month' produce seasonal definitions, so that Jan 1st 2015 and Jan 1st 2016 belon to the same category (e.g. "Q1" if 'TemporalCategory' is 'Quarter').
In order to make custom seasonal definitions, use the TemporalCategory'-option 'Custom' without providing years in 'CustomPeriods': "DD-MM". Periods defined in this way will automatically "wrap around" so that dates in January may grouped together with dates in December.
In order to make non-seasonal definitions for Quarter or Month, provide the 'CustomPeriods' for all years of interest on the format "DD-MM-YYYY". If years are provided the periods do not "wrap around" and categories are automatically extended to the entire year, if necesesarry. That is a category starting with 1. Jan is added if not present, and likewise a category ending with 31. Dec.
See also
AddPeriodStoxBiotic
and AddPeriodStoxLanding
for adding Periods to data.
Examples
# Define seasonal periods quarter
DefinePeriod(TemporalCategory = "Quarter")
#> Period StartDay StartMonth
#> 1: Q1 1 1
#> 2: Q2 1 4
#> 3: Q3 1 7
#> 4: Q4 1 10
# Define two periods "15th March - 15th Sep" and "15th Sep - 15th March"
DefinePeriod(TemporalCategory = "Custom", CustomPeriods = c("15-09", "15-03"))
#> Period StartDay StartMonth
#> 1: [15-03, 15-09> 15 3
#> 2: [15-09, 15-03> 15 9
# Add years to speficiation to define four periods "15th March 2015 - 31st Dec 2015" ...
DefinePeriod(TemporalCategory = "Custom", CustomPeriods = c("15-09-2105", "15-03-2015"))
#> Period StartDay StartMonth StartYear
#> 1: [01-01-2015, 15-03-2015> 1 1 2015
#> 2: [15-03-2015, 15-09-2105> 15 3 2015
#> 3: [15-09-2105, 31-12-2105> 15 9 2105
#> 4: [31-12-2105, 01-01-2015> 31 12 2105