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"

Recent Posts

R length(): Vector, List, Matrix, Array, Data Frame, String

Before executing an operation on an object, it is advisable to check its length, as…

1 day ago

How to Round Numbers in R

Rounding is a process of approximating a number to a shorter, simpler, and more interpretable…

2 days ago

Adding Single or Multiple Columns to Data Frame in R

Whether you want to add new data to your existing datasets or create new variables…

4 days ago

sqrt() Function: Calculate Square Root in R

The square root of a number is a value that is multiplied by itself, giving…

5 days ago

How to Remove Duplicate Rows from DataFrame in R

Duplicate rows refer to all the values across all columns that are the same in…

7 days ago

How to Remove NA From Vector in R

A vector is a data structure that holds the same type of data. When working…

1 week ago