SelectPeriodOnData {CSIndicators}R Documentation

Select a period on Data on multidimensional array objects

Description

Auxiliary function to subset data for a specific period.

Usage

SelectPeriodOnData(data, dates, start, end, time_dim = "time", ncores = NULL)

Arguments

data

A multidimensional array with named dimensions with at least the time dimension specified in parameter 'time_dim'. All common dimensions with 'dates' parameter need to have the same length.

dates

An array of dates with named dimensions with at least the time dimension specified in parameter 'time_dim'. All common dimensions with 'data' parameter need to have the same length.

start

A list with two elements to define the initial date of the period to select from the data. The first element is the initial day of the period and the second element is the initial month of the period.

end

A list with two elements to define the final date of the period to select from the data. The first element is the final day of the period and the second element is the final month of the period.

time_dim

A character string indicating the name of the dimension to compute select the dates. By default, it is set to 'time'. Parameters 'data' and 'dates'

ncores

An integer indicating the number of cores to use in parallel computation.

Value

A multidimensional array with named dimensions containing the subset of the object data during the period requested from start to end.

Examples

data <- array(rnorm(5 * 3 * 214 * 2),
             c(memb = 5, sdate = 3, time = 214, lon = 2)) 
Dates <- c(seq(as.Date("01-05-2000", format = "%d-%m-%Y"), 
              as.Date("30-11-2000", format = "%d-%m-%Y"), by = 'day'),
          seq(as.Date("01-05-2001", format = "%d-%m-%Y"), 
              as.Date("30-11-2001", format = "%d-%m-%Y"), by = 'day'),
          seq(as.Date("01-05-2002", format = "%d-%m-%Y"), 
              as.Date("30-11-2002", format = "%d-%m-%Y"), by = 'day'))
dim(Dates) <- c(time = 214, sdate = 3)
Period <- SelectPeriodOnData(data, Dates, start = list(21, 6), end = list(21, 9))

[Package CSIndicators version 1.1.1 Index]