library(rggobi)
library(MASS)

lcrabs <- crabs
lcrabs[,4:8] <- log10(crabs[, 4:8])
g <- ggobi(lcrabs)
d <- displays(g)[[1]]
pmode(d) <- "2D Tour"
variables(d) <- list(X=3:7) # 0-based
d2 <- display(g[1], "XY Plot")
# d2 <- displays(g)[[2]]
variables(d2) <- list(X=1, Y=2)
# now do linked brushing
close(d2)

crabs.grp <- factor(c("B", "b", "O", "o")[rep(1:4, each = 50)])
glyph_colour(g$lcrabs) <- crabs.grp
colorscheme(g) <- "Paired 4"

(lcrabs.pca <- princomp(lcrabs[4:8]))
loadings(lcrabs.pca)
lcrabs.pc <- predict(lcrabs.pca)
dimnames(lcrabs.pc) <- list(NULL, paste("PC", 1:5, sep = ""))
g$pca <- lcrabs.pc
d3 <- display(g$pca, "2D Tour")
glyph_colour(g$pca) <- crabs.grp

(pr <- ggobi_display_get_tour_projection(d3))
eqscplot(lcrabs.pc %*% pr, col=unclass(crabs.grp), pch=19)

## alternatively (with the plot in focus)
ggobi_display_save_picture(d3, "test.png")
## or use Tools | Save Display Description and
library(DescribeDisplay)
plot(dd_load("test.R"))

close(d3)

library(rgl)
plot3d(lcrabs.pc, type="s", size=0.2, col=crabs.grp)
