a

Not what you are looking for ? Make a new search !

`[mediatagger]`

Skip to content
# #3 R animated cube

wpDiscuz
a

Not what you are looking for ? Make a new search !

`[mediatagger]`

Is there anywhere we can get the codes for these graphs?

library( rgl )

z=iris

#colors vector

x=rep(0,150)

for (i in 1:150) {

if(z$Species[i] == “setosa”) x[i]=”royalblue1″

if(z$Species[i] == “versicolor”) x[i]=”darkcyan”

if(z$Species[i] == “virginica”) x[i]=”oldlace”

}

z$Color=x

plot3d( z[,1], z[,2], z[,3], col = z$Color, type = “s”, radius = .02 )

#We can indicate the axis and the rotation velocity

play3d( spin3d( axis = c(0, 0, 1), rpm = 7), duration = 10 )

#Save like gift

movie3d( spin3d( axis = c(0, 0, 1), rpm = 7),

duration = 10, dir = getwd(),

type = “gif”, clean = TRUE )