in R with Example

The is an inbuilt R constant. in R

The 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.



[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)[mnth]


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

That is it for the constant.



Leave a Comment