是否有将整数转换为英语等值的函数?即实现转型:
some_function(1) = 'one'
答案 0 :(得分:5)
使用english
包
library(english)
english(1:10)
# [1] one two three four five six seven eight nine ten
答案 1 :(得分:3)
some_function <- function(i) {
stopifnot(i %in% 1:9)
lookup <- c("one", "two", "three",
"four", "five", "six",
"seven", "eight", "nine")
lookup[i]
}
根据需要进行修改。