sprintf use without gsub

后端 未结 1 1775
北海茫月
北海茫月 2021-01-28 15:21

what is the more elegant way of just using sprintf without the gsub for this line of code?

gsub(\" \",\"0\",sprintf(\"%2.d\", 0:15))
[1         


        
相关标签:
1条回答
  • 2021-01-28 15:49

    Use a 0 in the format string to pad with leading zeros instead of spaces: sprintf("%02d", 0:15)

    0 讨论(0)
提交回复
热议问题