[R] Animated gif or something similar in R?

Dale Coons dale.coons at gmail.com
Thu Jul 28 22:14:03 CEST 2011


I'm have a (minor) problem and a question.
Problem: The following code creates 5 clusters of dots of different 
colors.  However, I need the second call outside the data.frame call to 
get the colors to change for some reason.  I assume there's an error in 
the data.frame() call, but I don't know what.
Question: Is there is a way to cause the resulting graphic to rotate on 
it's own and to output to a animated gif or some other format that could 
be used in a powerpoint type presentation?  I work with a bunch of 
'drama queens'--they'd like it if there was some motion rather than a 
static display ;-)

Thanks in advance,
Dale.

library(rgl)
clusset<-data.frame(x=c(round(abs(rnorm(5,7,1)),1),round(abs(rnorm(5,11,2)),1),
                         
round(abs(rnorm(5,16,2)),1),round(abs(rnorm(5,20,1.5)),1),round(abs(rnorm(5,5,2)),1)),
                     
y=c(round(abs(rnorm(5,7,2)),1),round(abs(rnorm(5,11,2)),1),
                         
round(abs(rnorm(5,16,2)),1),round(abs(rnorm(5,4,2)),1),round(abs(rnorm(5,7,2)),1)),
                     
z=c(round(abs(rnorm(5,7,2)),1),round(abs(rnorm(5,12,2)),1),
                         
round(abs(rnorm(5,16,1)),1),round(abs(rnorm(5,6,2)),1),round(abs(rnorm(5,17,2)),1)),
                     
dotcol=c(rep('red2',5),rep('green2',5),rep('blue2',5),rep('yellow1',5),rep('purple2',5))
                     )

#this call doesn't show the right colors--why?
plot3d(clusset, xlim=c(0,25), ylim=c(0,25), 
zlim=c(0,25),xlab='',ylab='',zlab='',  col=clusset$dotcol, radius=1, 
type='s')
#but if I redefine the colors again and call, it does
clusset$dotcol<-c(rep('red2',5),rep('green2',5),rep('blue2',5),rep('yellow1',5),rep('purple2',5))
plot3d(clusset, xlim=c(0,25), ylim=c(0,25), 
zlim=c(0,25),xlab='',ylab='',zlab='', col=clusset$dotcol, radius=1, 
type='s')



More information about the R-help mailing list