[R] Plotting point text-labels with lattice splom

Jockers Matthew mjockers at stanford.edu
Tue Sep 1 18:43:40 CEST 2009


I have read the thread re: "Plotting text with lattice" but can't seem  
to get from there to what I need. . . would appreciate any advice. . .

I have used splom to plot data of the first three principle components  
from a pca analysis.  Here is the code I have thus far:

 > mydata.pr<-prcomp(mydata)
 > grps <- substr(rownames(mydata),1,4)
 > super.sym=trellis.par.get("superpose.symbol")
 > splom(data.frame(mydata.pr$x[,1:3]),
	groups = grps,
	panel = panel.superpose,
	key = list (title = "Four Items in PCA space",
		text = list(c("G", "H", "N", "Il")),
		points=list(pch=super.sym$pch[1:4],
		col=super.sym$col[1:4])))

I would now like to append text labels to each point in the plot that  
will identify the item based on its rowname in the original data set.

so, something like this gets me the labels I want

 > labs<-substr(rownames(mydata),1,6)

My trouble then comes in figuring out how to get these labels to  
"attach" to the corresponding points in the plot.

Thanks.
Matt

--
Matthew Jockers
Stanford University
http://www.stanford.edu/~mjockers




More information about the R-help mailing list