Possible Duplicate:
Format number as fixed width, with leading zeros
sprintf use without gsub
This has probably been done before but I couldn't find a thread for R.
How would I increment leading zeroes in R?
For example have a vector called x with elements: 0001, 0002, 0003....9999