I have a column in my dataset with a bunch of numbers that are either five or six numbers long like below. However, all these need to be six numbers long. The dataset I have is from combining multiple excels together and the lead "0" in the five number long numbers disappeared in some of the excel but not in other, so I need to readd it to the five number long ones. So I need a function that finds any number that is five numbers long and then adds a 0 at the beginning so "49302" turns into 049302", but leaves the six number long observations as is. Any thoughts on how using gsub or another function to do this on a large dataset?
49302 038503 594030 39845 503932 334922 49403 84034