# prints the currently displayed graph, on device number dvnum, to the
# file filename; dvnum will typically be 2; filename must be the name of
# a PDF file, quoted; it closes the PDF file and restores dvnum as the
# current device

prpdf <- function(dvnum, filename)  {
   pdf(filename)
   dvc <- dev.cur()
   dev.set(dvnum)
   dev.copy(which=dvc)
   dev.set(dvc)
   dev.off()
   dev.set(dvnum)
}
