month.abb in R with Example

The month.abb is an inbuilt R constant.

month.abb in R

The month.abb is the three-letter abbreviations for the English month names. Sometimes date vector for months is recorded in numeric form, and it becomes difficult to treat or visualize it as a date vector.

For example, if the vector for months has numbers 1 that represents January, 2 that represents February, and so on, then it is considered as a numeric vector instead of the vector to represent the month.

Example

month.abb

Output

[1] "Jan" "Feb" "Mar" "Apr" "May" "Jun" "Jul" "Aug" "Sep" "Oct" "Nov" "Dec"

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 letters 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"

That is it for the month.abb constant.

 

 

Leave a Comment