For the purpose of styling data visualizations, I'd like to be able to display an integer using words (e.g.
"Two thousand and seventeen"
) rather than digits (e.g. 2017
).
As an example of what I'm looking for, here's a quick function that works for a small, scalar integer:
int_to_words <- function(x) {
index <- as.integer(x) + 1
words <- c('zero', 'one', 'two', 'three', 'four',
'five', 'six', 'seven', 'eight', 'nine',
'ten')
words[index]
}
int_to_words(5)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…