Counting the number of letters when we write out a sequence of numbers. As: 1, 2 is written as one, two - a total of 6 letters. We ignore whitespaces and hyphens.
Using the library english
library(english)
## Warning: package 'english' was built under R version 4.5.1
english(999)
## [1] nine hundred and ninety-nine
all_numbers_as_words <- english(1:1000)
Collapse that to a single string:
one_single_string <- paste0(all_numbers_as_words, collapse = "")
Remove whitespace:
without_ws <- gsub(" ", "", one_single_string)
Remove hyphens:
without_hyphens <- gsub("-", "", without_ws)
Count characters:
answers <- nchar(without_hyphens)