Description Usage Arguments Details Value References See Also Examples
View source: R/animation-methods.R
Proper function depends entirely on the
animation-package
, and details
regarding customization options can be found in its
documentation. In particular, the
ani.options
function can be
called beforehand to make animnation-related adjustments,
analogous to the way par
can be called for
base graphics. Similarly, most arguments to
ani.options
can be provided as additional named
arguments and will be passed on to ani.options
via
...
.
1 2 3 |
df |
(Required). A |
t |
(Recommended). A |
x |
(Recommended). A |
y |
(Recommended). A |
color |
(Optional). A |
shape |
(Optional). A |
ggplot2_expr |
(Optional). A
|
movie.name |
(Optional). A character string of the
desired name for the output movie file. Default is
|
... |
(Optional). Additional arguments passed to
|
Since this is an animation, one of the most important
arguments is t
, which specifies the variable
within the data.frame
(df
) that represents
time. This will be coerced to a numeric
,
and each unique value will be treated as a separate
time-step within the resulting animation. Note that in
most cases it should not be necessary to translate your
time measurement into time step integers, so long as the
values of t are coerceable to a numeric that represents
the correct order. If your time variable is a date
represented by the Date
class, it will
probably work fine. If in doubt, however, check that the
following code provides the correct order of
values.
as(df[, t], "numeric")
Similarly, the number of frames in the animation will be equal to
length(unique(as(df[, t], "numeric")))
so check that this value is what you need/expect.
A .gif
animation file. Support is planned for
other output file types supported by
animation
.
http://cran.r-project.org/web/packages/animation/animation.pdf
1 2 3 4 5 6 7 8 9 10 11 12 | ##### Define arbitrary, simple "data"
# x=1:10; y=x; t=x; sdf <- data.frame(x, y, t)
##### Make animation using animate() function:
# animate(sdf, "t", "x", "y")
##### Try an alternative "by hand" using base graphics:
# saveMovie( for(i in t){
# plot(subset(sdf, t<=i)[, c("x", "y")],
# xlim=c(min(sdf$x), max(sdf$x)),
# ylim=c(min(sdf$y), max(sdf$y))
# )
# })
#########
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.