[R] pad leading zeros in front of strings

Sarah Goslee sarah.goslee at gmail.com
Tue May 22 21:27:55 CEST 2012


On Tue, May 22, 2012 at 3:12 PM, Hui Du <Hui.Du at dataventures.com> wrote:
>
> Thanks all. I am trying to cleaning up user-inputted zip code. Most of them are pure numeric values but someone put characters in zipcode field, so I have to treat that field as a string rather than number.

But a padded invalid zip code, is still an invalid zip code. So why
not fix them first, then pad them? grepl() would be useful to identify
which have non-numeric characters.

Sarah



-- 
Sarah Goslee
http://www.functionaldiversity.org



More information about the R-help mailing list