R month.abb

The month.abb is a built-in R constant, a three-letter abbreviation for the English month names.

Example 1: Basic usage

month.abb

Output

[1] "Jan" "Feb" "Mar" "Apr" "May" "Jun" "Jul" "Aug" "Sep" "Oct" "Nov" "Dec"
Visual Representation of month.abb
Figure: Visual Representation of month.abb

Example 2: Changing abbreviations to numerical month values

If you have a vector of integers consisting of the number of the month, then you can use it to get the three-letter abbreviation of the month name by doing the following.

mnth <- c(12, 10, 8, 6, 4, 2)
month.abb[mnth]

Output

[1] "Dec" "Oct" "Aug" "Jun" "Apr" "Feb"

Leave a Comment