View source: R/rotation2dAnimation.r
rotation2dAnimation | R Documentation |
This function opens a graphics device to record the images produced in the
code expr
, then uses FFmpeg to convert these images to a video.
rotation2dAnimation(conf2d,
ani.interval=0.2,
ani.nmax=361,
ani.width=500,
ani.height=500,
ani.video.name="mds_rotate.mp4",
angle.start=-pi,
angle.stop=pi,
angle.step=pi/180)
conf2d |
two dimensional dataset ot matrix |
ani.video.name |
the file name of the output video (e.g. ‘animation.mp4’ or ‘animation.avi’) |
ani.interval |
interval betwwen animation frames |
ani.nmax |
maximal number of frames |
ani.width |
width of movie |
ani.height |
height of movie |
angle.start |
starting angle for animation |
angle.stop |
end angle for animation |
angle.step |
step of animation in radians |
This function uses system
to call FFmpeg to convert the images
to a single video. The command line used in this function is: ffmpeg
-y -r <1/interval> -i <img.name>%d.<ani.type> other.opts video.name
where interval
comes from ani.options('interval')
, and
ani.type
is from ani.options('ani.type')
. For more details on
the numerous options of FFmpeg, please see the reference.
Some linux systems may use the alternate software 'avconv' instead of 'ffmpeg'. The package will attempt to determine which command is present and set ani.options('ffmpeg')
to an appropriate default value. This can be overridden by passing in the ffmpeg
argument.
An integer indicating failure (-1) or success (0) of the converting
(refer to system
).
Marek Walesiak marek.walesiak@ue.wroc.pl, Andrzej Dudek andrzej.dudek@ue.wroc.pl
Department of Econometrics and Computer Science, Wroclaw University of Economics and Business, Poland
Walesiak, M. (2016), Visualization of Linear Ordering Results for Metric Data with the Application of Multidimensional Scaling, Ekonometria, 2(52), 9-21. Available at: \Sexpr[results=rd]{tools:::Rd_expr_doi("10.15611/ekt.2016.2.01")}.
Walesiak, M. (2017), The application of multidimensional scaling to measure and assess changes in the level of social cohesion of the Lower Silesia region in the period 2005-2015, Ekonometria, 3(57), 9-25. Available at: \Sexpr[results=rd]{tools:::Rd_expr_doi("10.15611/ekt.2017.3.01")}.
Walesiak, M., Dudek, A. (2017), Selecting the Optimal Multidimensional Scaling Procedure for Metric Data with R Environment, STATISTICS IN TRANSITION new series, September, Vol. 18, No. 3, pp. 521-540.
https://yihui.org/animation/example/savevideo/
http://ffmpeg.org/documentation.html
Other utilities: im.convert
,
saveGIF
, saveHTML
,
saveLatex
, saveSWF
library(mdsOpt)
library(smacof)
library(animation)
library(spdep)
library(clusterSim)
data(data_lower_silesian)
z<-data.Normalization(data_lower_silesian, type="n1")
d<-dist.GDM(z, method="GDM1")
res<-smacofSym(delta=d,ndim=2,type="interval")
konf<-as.matrix(res$conf)
#Uncomment only if ffmpeg is properly installed for animation package
#see: https://yihui.org/animation/example/savevideo/
#oopts = if (.Platform$OS.type == "windows") {
# ani.options(ffmpeg = "D:/Installer/ffmpeg/bin/ffmpeg.exe")
#}
#rotation2dAnimation(conf2d=konf,angle.start=-0,angle.stop=2*pi)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.