Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
sprintf在没有gsubfor 这行代码的情况下使用更优雅的方式是什么?
sprintf
gsub
gsub(" ","0",sprintf("%2.d", 0:15)) [1] "00" "01" "02" "03" "04" "05" "06" "07" "08" "09" "10" "11" "12" "13" "14" "15"
即我希望单个数字前面的零...作为字符输出。
在格式字符串中使用 a0来填充前导零而不是空格:sprintf("%02d", 0:15)
0
sprintf("%02d", 0:15)