baptiste auguie wrote: > sprintf("%04.f", 2) > makes no sense to use the float specifier for ints here; besides, it's slower:
x = 1:10^5 library(rbenchmark) benchmark(columns=c('test', 'elapsed'), replications=100, sprintf('%05d', x), sprintf('%05.f', x)) # test elapsed # 1 sprintf("%05d", x) 4.952 # 2 sprintf("%05.f", x) 10.019 > sapply(sample(1:1000,4), function(ii) sprintf("%04.f",ii)) sprintf is vectorized!!! > > ?sprintf indeed. vQ ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.