Animate dataframe

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Animate dataframe

Bart Joosen
Hi,
 
sorry for the double posting, but it seems my text was gone...

I'm running a code which does some alignment between data.
Now I want to follow the alignment while looping over the data.
 
I'm aware of the animation package, and saw the (easy) example where a plot
is animated by calling 100 times plot.
 
Is it possible to use this trick also for printing a dataframe to the
graphics device?
I tried already addtable2plot, but the table doesn't fit in the graphics
device (or I'm doing something wrong).
 
Here a simplified example of how the data looks and how it is filled:
 
dat <- data.frame(rows=rep(1:10, 15), columns=rep(1:15, each=10), result=NA)
dat$result <- NA
i = 0
while (!all(!is.na(dat$result))) {
        i = i + 1
        if (i==100) break
        dat$result[sample(1:nrow(dat),1)] <- rnorm(1)
}
 
in each loop should be something like:
print(as.data.frame(tapply(dat$result,list(rows=dat$rows,columns=dat$columns),
function(x) paste(x[x!=""],collapse="/"))))
 
Thanks
 
Bart
PS: I know that I can use a for loop instead of the while and if (i==100)
break construction, but hey, its an example, right? ;-)    
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.