R编程格式化数据
我想以3位格式存储一个数字数组,如001、002等。但当我尝试使用自动填充时,它只存储为1、2、3 在R编程中,如何将数字数组存储为001002等而不是1,2,3?我进行了搜索,但没有找到合适的答案。像这样使用sprintf:R编程格式化数据,r,formatting,R,Formatting,我想以3位格式存储一个数字数组,如001、002等。但当我尝试使用自动填充时,它只存储为1、2、3 在R编程中,如何将数字数组存储为001002等而不是1,2,3?我进行了搜索,但没有找到合适的答案。像这样使用sprintf: # create the n variable which is the number of numbers stored in the array n <- 10 vector <- sprintf("%03d", 1:n) 是了解sprintf命令更多信
# create the n variable which is the number of numbers stored in the array
n <- 10
vector <- sprintf("%03d", 1:n)
是了解sprintf命令更多信息的好网站
[1] “001” “002” “003” “004” “005” “006” “007” “008” “009” “010”