[R] recordPlot usage: add snaps to a list.

Paul E Johnson pauljohn at ukans.edu
Wed Jun 20 22:41:49 CEST 2001

I have trouble understanding the R list object and how to add objects
and get them out.  I'm trying to collect snapshots with recordPlot and
replay them.

Got great help from everybody here yesterday on my histogram function,
works fine to make the pictures:

histomatic <- function (s1,s2,s3,var){
  if (is.numeric (s2[[var]])) {     
  rz <- range(s1[[var]], s2[[var]], s3[[var]]);
  breaks <- pretty(rz,40);
  hist(s2[[var]], breaks=breaks,xlab=var,main="Randomized Master
  hist(s3[[var]], breaks=breaks,xlab=var,main="Decentralized Dynamic

Note I add in the a<-recordPlot() to try to keep a snapshot. That value
a gets returned.  I have tried in many many ways to add that snap a onto
a list of snaps, but all have failed, making me think list does not mean
what I think it does.  A

#intitialize a list
pictureList <- list();  
#loop through variable names, take return from each histomatic call, and
#to pictureList.
for (var in nameList)
  if (is.numeric (RandMastMod0[[var]])) {     
  pictureList <- c(pictureList,

After that, pictureList is not a null thing, 
> attributes(pictureList)
  [1] "displaylist" "gpar"        "displaylist" "gpar"       
  [6] "gpar"        "displaylist" "gpar"        "displaylist" "gpar"
 [11] "displaylist" "gpar"        "displaylist" "gpar"       

but i can't see how to access the snapshots from replayPlot().  Adding
the images into the list flattens them and makes the class of the items
no longer equal "recordedplot".

> replayPlot(pictureList[[1]])
Error in if (class(x) != "recordedplot") stop("argument is not of class
\"recordedplot\"") :
        missing value where logical needed

Paul E. Johnson                       email: pauljohn at ukans.edu
Dept. of Political Science            http://lark.cc.ukans.edu/~pauljohn
University of Kansas                  Office: (785) 864-9086
Lawrence, Kansas 66045                FAX: (785) 864-5700
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch

More information about the R-help mailing list