Skip to content

Commit

Permalink
PavoDive fix for 4 digits
Browse files Browse the repository at this point in the history
  • Loading branch information
joseazdir committed May 3, 2024
1 parent 616efb5 commit 27b4f64
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions R/to_words.R
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,19 @@ to_words <- function(x) {

} else if (len == 4) {

x <- as.vector(paste0(units[digits[4]],"mil ",hundred[digits[3]]," ", if (as.numeric(paste0(digits[2],digits[3])) <= 19) as.vector(dozens[digits[1]]) else as.vector(paste0(tens[digits[2]]," y ", units[digits[1]]))))

#x <- as.vector(paste0(units[digits[4]],"mil ",hundred[digits[3]]," ", if (as.numeric(paste0(digits[2],digits[3])) <= 19) as.vector(dozens[digits[1]]) else as.vector(paste0(tens[digits[2]]," y ", units[digits[1]]))))
x <- as.vector(
paste0(
units[digits[4]], "mil ", ## thousands, no changes
hundred[digits[3]], " ", ## hundreds, no changes
ifelse(
as.numeric(paste0(digits[2], digits[3])) < 10, ## in case there are no tens (numbers ending in 0x), this is the main change
units[digits[1]], ## return only the units
ifelse(as.numeric(paste0(digits[2], digits[3])) <= 19, # these are the cases with the weird names, no changes from here on
as.vector(dozens[digits[1]]),
as.vector(paste0(
tens[digits[2]]," y ",
units[digits[1]]))))))
}


Expand Down

0 comments on commit 27b4f64

Please sign in to comment.