Reputation: 385
Is there a function to transform integers into their English equivalents? I.e. to achieve the transformation:
some_function(1) = 'one'
Upvotes: 1
Views: 503
Reputation: 81693
Use the english
package
library(english)
english(1:10)
# [1] one two three four five six seven eight nine ten
Upvotes: 5
Reputation: 132706
some_function <- function(i) {
stopifnot(i %in% 1:9)
lookup <- c("one", "two", "three",
"four", "five", "six",
"seven", "eight", "nine")
lookup[i]
}
Modify as needed.
Upvotes: 3