Learn R Programming

pgirmess (version 2.0.2)

date2winter: Convert a POSIXt date into categories corresponding to a autumn/winter/spring sequence

Description

Convert a POSIXt date into categories corresponding to the time spanning from the late months of a year to the early months of the following year

Usage

date2winter(x, first = 10, last=4)

Value

A vector of the same length as x, with the time span category each value belongs to.

Arguments

x

a vector of POSIXt dates

first

number of the first month to include (default 10, October)

last

number of the last month to include (default 4, April)

Details

In ecology, time data must often be analysed on a time span category covering two successive years (e.g. the winter period). This function convert POSIXt dates into categories corresponding to the time span stretching from a user defined month of a given year (by default October) to a user-defined month of the following year (by default April). If date month is out of the user defined time span the value 'Excluded' is returned.

Examples

Run this code
 dates <- strptime(c("02/12/2002", "15/01/2003","15/10/2003","15/6/2003",NA),"%d/%m/%Y")
 date2winter(dates)

Run the code above in your browser using DataLab