RGL is needed for nice interactive 3d plots in R, but a pain to find out how to build on a modern OSX machine.
“The rgl package is a visualization device system forĀ R, using OpenGL as the rendering backend. An rgl device at its core is a real-time 3D engine written in C++. It provides an interactive viewpoint navigation facility (mouse + wheel support) and an R programming interface.”
The following commands worked for me in OSX Snow Leopard:
- svn checkout svn://svn.r-forge.r-project.org/svnroot/rgl
- R CMD INSTALL ./rgl/pkg/rgl –configure-args=”–disable-carbon” rgl
Here’s a test that should give an interactive 3D display if all went well, using a built-in dataset:
library(rgl) cars.data <- as.matrix(sweep(mtcars[, -1], 2, colMeans(mtcars[, -1]))) # cargo cult'd xx <- svd(cars.data %*% t(cars.data)) xxd <- xx$v %*% sqrt(diag(xx$d)) x1 <- xxd[, 1] y1 <- xxd[, 2] z1 <- xxd[, 3] plot3d(x1,y1,z1,col="green", size=4) text3d(x1,y1,z1, row.names(mtcars))
After many hours spent on this I still didn’t make it work but will keep on trying..
Thanx for the info anyway
website design
Update: http://www.r-bloggers.com/r-interactive-3d-webgl-plot-of-time-space-cube-with-rgl/ makes it all worthwhile!