R Basic

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"
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"
Share
Published by
Krunal Lathiya

Recent Posts

Understanding the as.numeric() Function in R

Data occasionally comes in various formats, including numeric values stored as text (characters) or categories…

3 weeks ago

How to Append an Element to a List at Any Position in R

When you don't know the size of your data, you can use the "list" data…

4 weeks ago

How to Convert List to Numeric in R

To convert a list to a numeric value in R, you can combine the unlist()…

1 year ago

How to Use “lwd” in R

The lwd in R is used to specify the width of plot lines. It is…

1 year ago

How to Convert Double to Integer in R

To convert a double or float to an integer, you can use the "as.integer()" function.…

1 year ago

R dirname() Function

The dirname() function in R is used to extract the path to the directory from…

1 year ago