Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert month's number to Month name

Tags:

date

r

I need to convert this integer vector which contains the number of months in the year to month's name.

for example :

1
2
3

The expected result should be :

January
February
March

How can I do this, please? Thank you for your suggestions!

like image 539
Rprogrammer Avatar asked May 30 '18 14:05

Rprogrammer


1 Answers

We can just use month.name to change the index of months to its corresponding name

month.name[v1]

and there is also a 3 character abbreviation for month

month.abb[v1]

data

set.seed(24)
v1 <- sample(1:12, 24, replace = TRUE)
like image 83
akrun Avatar answered Sep 18 '22 22:09

akrun