I'd like to make a sequence of numbers with a character in R as below.
[H01, H02, H03, ... , H24]
I can only generate numbering characters like
[H1, H2, H3, ... , H24]
with a command
paste0("H", 1:24)
any tips for this?
I'd like to make a sequence of numbers with a character in R as below.
[H01, H02, H03, ... , H24]
I can only generate numbering characters like
[H1, H2, H3, ... , H24]
with a command
paste0("H", 1:24)
any tips for this?
sprintf
is similar with printf
of C, so you can control the format exactly as below:
sprintf("H%02d", 1:24)
[1] "H01" "H02" "H03" "H04" "H05" "H06" "H07" "H08" "H09" "H10" "H11" "H12" "H13" "H14" "H15" "H16" "H17" "H18" "H19" "H20" "H21"
[22] "H22" "H23" "H24"
Also see this.