Learn R Programming

tdata (version 0.3.0)

get.seq: Generate a Sequence from a Range of Frequencies

Description

Use this function to generate a list of character strings, where each element is a string representation of a frequency within the specified range.

Usage

get.seq(from, to, by = 1)

Value

A list of character strings that represents the sequence.

Arguments

from

The first frequency of the sequence.

to

The last frequency of the sequence.

by

An integer that determines the increment of the sequence.

Details

The two arguments from and to should be valid frequencies (see the f.? functions). They should also be consistent; you cannot create a sequence in which one is, for example, monthly and the other is yearly.

See Also

get.seq0

Examples

Run this code
from <- f.monthly(2020,1)
to <- f.monthly(2021,12)
sequence1 <- get.seq(from, to, 1) # this will be '2020M1', '2020M2', ..., '2021M12'
sequence2 <- get.seq(from, to, 2) # this will be '2020M1', '2020M3', ..., '2021M11'
sequence3 <- get.seq(from, to, 3) # this will be '2020M1', '2020M4', ..., '2021M10'

# backward:
sequence4 <- get.seq(to, from, -1) # this will be '2021M12', '2021M11', ..., '2020M1'

Run the code above in your browser using DataLab