Q:

Generate Sequence of Numbers in R with two digit

I have a matrix,and i need to generate column name to the matrix.
column names should be something like this.
"out01"  "out02"  "out03"  "out04" ... to .. "out30"

This is what i have tried
outmat <- matrix(NA, 5, 30)
colnames(outmat) <- sprintf("out%d", 1:30)

generated column names are like this.
 "out1"  "out2"  "out3"  "out4"  "out5"  "out6"  "out7"  "out8"  "out9"  "out10" .... to "out30"

is there any direct way to covert out1 to out01 in sprintf method.

A:

Yes, specify %02d 
sprintf("out%02d", 1:30)
#[1] "out01" "out02" "out03" "out04" "out05" "out06" "out07" "out08" "out09"....

