dtQuarter#

Purpose#

Extracts the quarter from a date/time variable (1-4).

Format#

qtrs = dtQuarter(X[, column])#
Parameters:
  • X (TxK dataframe) – Data with metadata.

  • column (Scalar or string) – Optional, name or index of the date variable in X to get quarters from. Default = first column.

Returns:

qtrs (Tx1 vector) – The numeric quarter (1-4) of the dates in the column specified by columns.

Examples#

// Load data
fname = getGAUSSHome("examples/yellowstone.csv");
data = loadd(fname);

// Get quarters for date column
qtrs = dtQuarter(data, "Date");

// Print first five and last five observations
head(data[., "Date"]);
tail(data[., "Date"]);

// Print corresponding quarters
"Quarters:";
head(qtrs);
tail(qtrs);

The code above prints the following table:

  Date
2016/01/01
2015/01/01
2014/01/01
2013/01/01
2012/01/01

      Date
1990/12/01
1989/12/01
1988/12/01
1987/12/01
1986/12/01

 Quarters:
         1
         1
         1
         1
         1

         4
         4
         4
         4
         4