[R] "%03d" in the pdf command
(Ted Harding)
Ted.Harding at nessie.mcc.ac.uk
Sat Jul 23 23:23:08 CEST 2005
On 23-Jul-05 Prof Brian Ripley wrote:
> On Sat, 23 Jul 2005, Dennis Fisher wrote:
>
>> The pdf man page contains the following text:
>>
>> pdf(file = ifelse(onefile, "Rplots.pdf", "Rplot%03d.pdf"),
>> width = 6, height = 6, onefile = TRUE, family = "Helvetica",
>> title = "R Graphics Output", fonts = NULL, version = "1.1",
>> paper, encoding, bg, fg, pointsize)
>>
>> I am creating multi-page graphics in which each page is saved as a
>> separate file. If I invoke onefile=T and I include "%03d" in the
>> filename, each page is saved as a separate file. However, I don't
>> understand the "%03d". Can someone explain? Am I calling a register
>> that contains the page number?
>
> See ?sprintf, or man printf on your system.
> It formats the page number in that C format.
If it's still obscure, the effect of the format string "Rplot%03d.pdf"
is that a string is generated consisting of the characters
Rplot
followed by
an integer of width 3 digits (padded to the left with zeros
if required to make the width equal to 3),
followed by the characters
d.pdf
where the value to be inserted in place of "%3d" will be derived
from somewhere -- not specified in the command itself but deducible
from "?pdf": If onefile=TRUE then you get all figures in a single
file whose name is "Rplots.pdf", otherwise you get them succesively
in separate files with names
Rplot001.pdf
Rplot002.pdf
Rplot003.pdf
Rplot004.pdf
...
Rplot998.pdf
Rplot999.pdf
after which you run out of road.
Hoping this helps,
Ted.
--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 23-Jul-05 Time: 22:22:15
------------------------------ XFMail ------------------------------
More information about the R-help
mailing list