my data set has codes which are supposed to be 5 digits. However, there are a few with 4 digits. I want to add leading zeros in front of those values with 4 digits. I used the following code:
labos$postal1 <- sprintf("%05d", labos$postal)
This command added zeros in front of all the values, including those with 5 digits.
Help me add zeros just to the values with 4 digits.