将月份的数字转换为月份的名称

将月份的数字转换为月份的名称

问题描述:

我需要将包含一年中月份数的整数向量转换为月份的名称。

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

例如:

1
2
3

预期结果应为:

January
February
March

请问我该怎么做?
谢谢您的建议!

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

我们只能使用 month.name 将月份的索引更改为其相应的名称

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

month.name[v1]

,月份也有3个字符的缩写。

and there is also a 3 character abbreviation for month

month.abb[v1]



data



data

set.seed(24)
v1 <- sample(1:12, 24, replace = TRUE)