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]])) {
par(mfrow=c(3,1));
rz <- range(s1[[var]], s2[[var]], s3[[var]]);
breaks <- pretty(rz,40);
hist(s1[[var]],breaks=breaks,xlab=var,main="Baseline");
hist(s2[[var]], breaks=breaks,xlab=var,main="Randomized Master
Schedule");
hist(s3[[var]], breaks=breaks,xlab=var,main="Decentralized Dynamic
Schedule");
a<-recordPlot();
}
}
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
append
#to pictureList.
for (var in nameList)
if (is.numeric (RandMastMod0[[var]])) {
pictureList <- c(pictureList,
histomatic(NoFlagMod0,RandMastMod0,NoMastMod0,var));
}
After that, pictureList is not a null thing, > attributes(pictureList)
$names
[1] "displaylist" "gpar" "displaylist"
"gpar"
"displaylist"
[6] "gpar" "displaylist" "gpar"
"displaylist" "gpar"
[11] "displaylist" "gpar" "displaylist"
"gpar"
"displaylist"
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._