f.list.dateR Documentation

Create a List-Date Frequency

Description

Use this frequency for data with date labels. It is generally a list of dates, but it can also be used to label observations outside this list.

Usage

f.list.date(items, value = NULL, reformat = TRUE)

Arguments

items

The items in the list in YYYYMMDD format.

value

The current value in YYYYMMDD format. If null, the first value in items is used.

reformat

If the elements of items are not in YYYYMMDD format, set this to be TRUE.

Details

In order to use the as.frequency function for this type of frequency, you need the following information:

Value

An object of class ldtf. It is also a list with the following members:

class

Determines the class of this frequency.

items

Determines the items.

value

Determines the value.

Examples


Ld0 <- f.list.date(c("20231101","20220903","20200823","20230303"), "20200823")

Ld0_value_str <-  as.character(Ld0) # this will be '20200823'.
Ld0_class_str <- get.class.id(Ld0)
#      this will be 'Ld:20231101;20220903;20200823;20230303'.

Ld_new <- as.frequency("20231101", "Ld:20231101;20220903;20200823;20230303")
Ld_new0 <- as.frequency("20231101", "Ld")
#     compared to the previous one, its items will be empty

# Don't make the following mistakes:

Ld_invalid <- try(as.frequency("20231102", "Ld:20231101;20220903;20200823;20230303"))
  # 'E' is not a member of the list
Ld_invalid <- try(f.list.date(c("20231101","20220903","20200823","20230303"), "20231102"))