sprintf use without gsub

后端 未结 1 1774
北海茫月
北海茫月 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)
提交回复
热议问题