Mario dos Reis wrote:
> I've been trough the R documentation for about half an hour and it's
> not clear to me how to do this:
>
> I need to format to character a series of integers from 1 to 1000, and
> I like them to look like
>
> "0001" "0002", "0059", "0123" and so on. Padded with zeroes to have
> four digits.
    # dummy data
    x = sample(100, 10)

    # formatting
    sprintf('%04d', x)

vQ

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to