dtDayName#

Purpose#

Extracts the day component from a date/time variable as a string name.

Format#

day_names = dtDayName(X[, columns, abbreviate])#
Parameters:
  • X (TxK dataframe) – Data with metadata.

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

  • abbreviate (Scalar) – Optional, indicator variable to abbreviate months. Set to 1 to abbreviate names. Default = 0.

Returns:

day_names (Tx1 string array) – the name of the day components of the dates contained in the Jx1 columns specified by columns.

Examples#

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

// Get day of the week names for date column
day_names = dtDayName(data, "Date");

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

// Print corresponding day names
"Name of day:"
head(day_names);
tail(day_names);

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

Name of day:

      Friday
    Thursday
   Wednesday
     Tuesday
      Sunday

    Saturday
      Friday
    Thursday
     Tuesday
      Monday

The abbreviated names can be obtained using the optional abbreviate input.

// Get day names for date column
day_names = dtDayName(data, "Date", 1);

// Print corresponding day names
"Name of day:"
head(day_names);
tail(day_names);

The code above prints the following table:

Name of day:

        Fri
        Thu
        Wed
        Tue
        Sun

        Sat
        Fri
        Thu
        Tue
        Mon