📜  sprintf R 示例 - 任何代码示例

📅  最后修改于: 2022-03-11 14:56:29.560000             🧑  作者: Mango

代码示例1
sprintf("%06d", 12)           #  "000012" - leading zeros for 6 digits

x <- 123.456 
sprintf("%f", x)           # "123.456000" - sprintf with default specification 
sprintf("%.10f", x)        # "123.4560000000" - sprintf with ten decimal places
sprintf("%.2f", x)         # "123.46" - sprintf with two rounded decimal places
sprintf("%1.0f", x)        # "123" - sprintf without decimal places
sprintf("%-15f", x)        # "123.456000" - Space on right side
sprintf("%+f", x)          # "+123.456000" - Print plus sign before number