Whoops I missed that,
if the sign might or might not be present for a given transaction, it goes back to being a fixed number of numerals problem if separating, as you want to preserve the -
df <- data.frame(example1=c("001-","002-","003-","004-"),
example2=c("001-","002-","003","004"))
library(tidyr)
library(dplyr)
#treating as numeric, losing leading 0s
df %>%
separate(example1, into=c("example1", "sign1"), sep=3, fill="right") %>%
separate(example2, into=c("example2", "sign2"), sep=3, fill="right") %>%
mutate(example1 = if_else(sign1 == "-", -1 * as.double(example1), as.double(example1)),
example2 = if_else(sign2 == "-", -1 * as.double(example2), as.double(example2)))
#treating as text, keeping leading 0s
df %>%
separate(example1, into=c("example1", "sign1"), sep=3, fill="right") %>%
separate(example2, into=c("example2", "sign2"), sep=3, fill="right") %>%
mutate(example1 = paste0(sign1,example1),
example2 = paste0(sign2,example2))