month.name in R with Example

The month.name is an inbuilt R constant.

month.name in R

The month.name is the English name for the months of the year. 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.name

Output

[1] "January" "February" "March"     "April"   "May"      "June"
[7] "July"    "August"   "September" "October" "November" "December"

Changing Month Names 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 Month Names by doing the following.

mnth <- c(11, 9, 4, 2)
month.name[mnth]

Output

[1] "November" "September" "April" "February"

That is it for the month.name constant.

See also

month.abb

LETTERS in R

letters in R

pi in R

Leave a Comment