Dear S+ Users,
To create animation, I want the result of each plotting command within a
function to be displayed immediately upon completion of that command.
As is, everything is plotted upon exit (return) from the function.
How can I force the immediate display to a graphic window of the result of
a plotting command that is part of a function?
I am running v. 4.0 release 3 for Windows.
Example:
test.plot<- function(n)
{
# Plot three point, one at a time.
# Display each point once plotted.
x<- c(1,2,3)
y<- c(1,2,1)
plot(x,y, type="n")
nobs <- length(x)
for(i in 1:nobs) {
points(x[i], y[i])
pause(n) # pause for n sec
}
}
The pause function was kindly provided by Bert Gunter
pause<- function(n)
{
start <- proc.time()
while(proc.time() < (start + n)) {
#do nothing
}
cat("all done\n")
}
Thanks in advance!
Terje Jorgensen
Gear Section
Institute of Marine Research, Bergen
Norway
e-mail: terjej@imr.no
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news
|