[R] Converting integers to chars i.e 1 to "01"

Thomas Petzoldt thpe at hhbio.wasser.tu-dresden.de
Wed Jan 5 11:18:25 CET 2005


Gregor GORJANC wrote:
> Hello!
> 
> I am producing a set of images and I would like them to be sorted by 
> names I give. I was able to produce my names and add integer to them. 
> That is easy. But my problem lies in sort of file from this process:
> 
> figure_10.png
> figure_11.png
> figure_12.png
> ...
> figure_1.png
> figure_20.png

One simple solution for sortable file names is to add a large integer to 
your index i:

png(filename=paste("figure_", i + 1000, ".png", sep=""))

Thomas P.




More information about the R-help mailing list