Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R编程格式化数据_R_Formatting - Fatal编程技术网

R编程格式化数据

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命令更多信

我想以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命令更多信息的好网站
[1] “001” “002” “003” “004” “005” “006” “007” “008” “009” “010”