[R] PDF output problem
Andre Rabello DOS ANJOS
Andre.dos.Anjos at cern.ch
Tue Aug 27 18:09:34 CEST 2002
Hello,
I'm quite new to R, but I've already stepped into this problem:
I open a PDF device with:
pdf("Name-%d.pdf", width=10, height=10, onefile=FALSE)
And draw 4 histograms in a row, expecting the pdf device to
automatically number them from 1 to 4. What I get back is
only 2 images with names "Name-1.pdf" and "Name-2.pdf" that
contain the two last histograms I've plotted. Is it a known
problem? Or am I doing something wrong here?
I attach the script to this message in the hope somebody knows
the cause of this strange behaviour. Thanks in advance for
any help.
Andre.
--
Andre Rabello DOS ANJOS, M.Sc.
Signal Processing, Data Analysis and Computing
Office: 32-2-A06, Tel: (+ 41 22) 767 5022
Fax: (+ 41 22) 767 8420
CERN - EP/HC Division
CH-1211 Geneve 23 - Suisse/Switzerland
http://cern.ch/rabello
-------------- next part --------------
# Hello emacs (ess), this is -*- R -*-
# $Id$
# Andre DOS ANJOS <Andre.dos.Anjos at cern.ch>
# This script will run R, producing histograms
# generated with data from nat.
# Calculates the standard deviation of a vector
std <- function (x) {
return(sqrt(sum((x-mean(x))^2)/(length(x)-1)))
}
# This function will produce a fancy histogram in R. The histogram,
# besides having the normal look, will display the total number of
# entries, the average and standard deviation (aka, sigma).
nathist <- function (d, breaks = "Sturges",
main = "NetLogger Histogram",
xlab = expression(paste("Time (", mu, "s)")),
ylab = "Counts") {
r <- hist(d, breaks=breaks, main=main, xlab=xlab, ylab=ylab,
border='black', col='yellow')
y <- max(r$counts) * 0.9
x <- r$breaks[length(r$breaks)-1] * 0.7
text(x, y, paste("Entries: ", length(d)), pos=4, col='blue3')
text(x, 0.97*y, paste("Average: ",mean(d)), pos=4, col='blue3')
text(x, 0.94*y, paste("Deviation: ",std(d)), pos=4, col='blue3')
rect(0.99*x, 0.92*y, 0.99*r$breaks[length(r$breaks)], y*1.03,
border='black')
##text(r$mids, r$counts*1.005, r$counts, pos=3)
## return(r)
}
#Set the column names
colname <- c("ROW.NAMES", "PUT.L1RESULT", "GET.L1RESULT", "START.PROCESSING",
"GAUDI.START.ALGO.PROCESSING", "ROSDATA.REQUESTED.1",
"ROSDATA.RECEIVED.1", "ROSDATA.REQUESTED.2",
"ROSDATA.RECEIVED.2", "GAUDI.END.ALGO.PROCESSING",
"END.PROCESSING", "SEND.L2DECISION", "DELETE.L1MESG")
#Read-in the data table
my <- read.table("file.dat", col.names=colname, row.names=1)
# Data Transfer Overhead
datareq = my[,"ROSDATA.RECEIVED.1"] - my[,"ROSDATA.REQUESTED.1"] +
my[,"ROSDATA.RECEIVED.2"] - my[,"ROSDATA.REQUESTED.2"]
pdf(file="nat-rose.pdf", heigh=10, width=10, onefile=TRUE)
nathist(datareq, main="L2PU/ROSE Data Transfer Overhead", breaks=25)
# Gaudi Timings
gaudi = my[,"GAUDI.END.ALGO.PROCESSING"] -
my[,"GAUDI.START.ALGO.PROCESSING"] - datareq
pdf(file="nat-pesa.pdf", heigh=10, width=10, onefile=TRUE)
nathist(gaudi, main="PESA Timings", breaks=50)
# L2PU Overhead
l2pu = my[,"DELETE.L1MESG"] - my[,"GET.L1RESULT"] - datareq - gaudi
pdf(file="nat-l2pu.pdf", heigh=10, width=10, onefile=TRUE)
nathist(l2pu, main="L2PU Overhead", breaks=50)
# Queue Timing
queue = my[,"GET.L1RESULT"] - my[,"PUT.L1RESULT"]
pdf(file="nat-queue.pdf", heigh=10, width=10, onefile=TRUE)
nathist(queue, main="Queue Timings", breaks=50)
graphics.off()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 232 bytes
Desc: not available
Url : https://stat.ethz.ch/pipermail/r-help/attachments/20020827/4d6cf11b/attachment.bin
More information about the R-help
mailing list