答案 0 :(得分:1)
您可以按照Ronak Shah的建议使用cut
函数
cut(1:31, breaks = c(0, 10, 20, 31), labels = c("early month", "mid month", "end month")
# [1] early month early month early month early month early month early month
# [7] early month early month early month early month mid month mid month
# [13] mid month mid month mid month mid month mid month mid month
# [19] mid month mid month end month end month end month end month
# [25] end month end month end month end month end month end month
# [31] end month
# Levels: early month mid month end month