Good day everyone. I have a question concerning *ggobi* and
*rggobi*package. I am using R version 2.13.2 and Ubuntu 11.04. I am
new to ggobi
and I'm reading the book *Interactive and Dynamic Graphics for Data Analysis
*. The book was published 2007.

My question is: how can I export a graph for *rggobi* to pdf to include it
in latex. For example: I have lots of variables in ggobi and I need to
export the ggplot like scatterplot of any two variables or parallel
cordinates graph to a pdf. So far I've read that the authors suggests to
solve it like this:

library(DescribeDisplay)
d <- dd_load("fig.R")
plot(d)

or

p <- ggplot(d)
print(p)

which produces nice graphics which you can use with pdf() function. But
neither the *DescribeDisplay* package, nor *ggplot* are available in
2.13.2.

I browsed the web for solution, but I found only that
ggobi_display_save_picture() could be useful for image graphs but not for
pdf. I also tried save display description (tools->save display
description) and then plotting it with qplot() or plot(). But all I get is
a blank screen while ggobi_display_save_picture() gives a good picture.
There is probably a much easier solution since R is changing and becoming
more convenient to use.

I i'm also including the code of the example i'm doing


f.std.data<-function(x) {
  return((x-mean(x,na.rm=T))/sd(x,na.rm=T))
}

# Read data, and standardize before running SOM

d.music<-read.csv("music-sub.csv",row.names=1)
d.music.std<-cbind(d.music[,c(1,2)],apply(d.music[,-c(1,2)],2,f.std.data))



# Load libraries
library(rggobi)
library(som)

# Run SOM

music.som<-som(d.music.std[,-c(1:2)],6,6,neigh="bubble",rlen=100)
music.som<-som(d.music.std[,-c(1:2)],6,6,neigh="bubble",rlen=1000)

# Set up data for ggobi - data needs to have any labels in the first few columns

f.ggobi.som<-function(x,x.som) {
  xmx<-jitter(x.som$visual$x,factor=2)
  xmy<-jitter(x.som$visual$y,factor=2)
  ncols<-ncol(x)
  x.ggobi<-cbind(x,xmx,xmy)
  dimnames(x.ggobi)[[2]][ncols+1]<-"Map 1"

  dimnames(x.ggobi)[[2]][ncols+2]<-"Map 2"
  x.grid<-cbind(x.som$code,x.som$code.sum[,1:2])
  dimnames(x.grid)[[2]]<-dimnames(x.ggobi)[[2]]
  x.clust<-rbind(x.ggobi,x.grid)
}
f.ggobi.som.net<-function(x.som) {

  x.net<-NULL
  for (i in 1:x.som$xdim) {
    for (j in 1:x.som$ydim) {
        if (j<x.som$ydim)
x.net<-rbind(x.net,c((i-1)*x.som$xdim+j,(i-1)*x.som$xdim+j+1))

    if (i<x.som$xdim) x.net<-rbind(x.net,c((i-1)*x.som$xdim+j,i*x.som$xdim+j))
    }
  }
  return(x.net)
}

d.music.som<-f.ggobi.som(d.music.std[,-c(1,2)],music.som)

d.music.som<-list(Songs=factor(c(as.character(row.names(d.music)),rep("0",36))),
  Artist=factor(c(as.character(d.music[,1]),rep("0",36))),
  Type=factor(c(as.character(d.music[,2]),rep("0",36))),

  LVar=d.music.som[,1],LAve=d.music.som[,2],LMax=d.music.som[,3],
  LFEner=d.music.som[,4],LFreq=d.music.som[,5],Map.1=d.music.som[,6],
  Map.2=d.music.som[,7])
gg<-ggobi(d.music.som)
g<-gg[1]

#load edges
d.music.som.net<-f.ggobi.som.net(music.som)
edges(g) <- d.music.som.net + 62

# Color points according to type of music, and som net

gcolor<- rep(8,98)
gcolor[d.music.som$Type=="Rock"]<-6
gcolor[d.music.som$Type=="Classical"]<-4
gcolor[d.music.som$Type=="New wave"]<-1
glyph_color(g)<-gcolor

	[[alternative HTML version deleted]]

