I would like to add leading zeros to the alphanumeric string for just ten characters. It is possible, however, that there is a space between the characters.
TestID <- c("1b4 7A1") gsub(" ","0",sprintf("%010s", TestID))
This code adds leading zeros, but also replaces the empty space inside the string with zero. Is there a way to add zeros just before the string?
# [1] "0001b4 7A1"
count source share