textclean icon indicating copy to clipboard operation
textclean copied to clipboard

replace_time error with repeating time values

Open gcpoole opened this issue 3 months ago • 0 comments

replace_time has an issue with repeating values.

This is fine:

> c("01:30", "02:30", "3:30") |> textclean::replace_time()
[1] "one thirty"   "two thirty"   "three thirty"

Repeated value at beginning and end gets correct answer, with warning:

> c("01:30", "02:30", "3:30", "01:30") |> textclean::replace_time()
[1] "one thirty"   "two thirty"   "three thirty" "one thirty"  
Warning message:
In as.data.table.list(x, keep.rownames = keep.rownames, check.names = check.names,  :
  Item 2 has 3 rows but longest item has 4; recycled with remainder.

Repeated value in middle puts results in wrong order, with warning:

> c("01:30", "02:30", "3:30", "01:30", "2:30") |> textclean::replace_time()
[1] "one thirty"   "two thirty"   "three thirty" "two thirty"   "one thirty"  
Warning message:
In as.data.table.list(x, keep.rownames = keep.rownames, check.names = check.names,  :
  Item 2 has 4 rows but longest item has 5; recycled with remainder.

gcpoole avatar Sep 09 '25 20:09 gcpoole