On Wed, 2007-11-14 at 16:46 +0100, Elisa Santi wrote: > I'm using cocorresp package with predictive co-correspondence analysis > model. > i would need to visulize inside the graphic (plot function) the sample > site numbers (is it possible to consider this a "label"?). > is there any function to do this? > > thanks for your help. > > Elisa
Dear Elisa, The posting guide asks you to direct questions about contributed packages to the maintainer not the list. So that'd be me then... The default plotting functions in cocorresp are very rudimentary and reflect what I knocked up at the time to visualise the output simply. I've somewhat neglected the package for a while due to work commitments and a need to finish another package for a research project. Updating the package is on my TODO list but that is a rather long list at the moment. In the interim, here's an example of how to alter the plotting which will hopefully get you started. If you have other questions, please direct them to me rather than the list. require(cocorresp) data(beetles) data(plants) bp.pred <- coca(beetles ~ ., data = plants, n.axes = 2) ## get the scores for plotting bp.sc <- scores(bp.pred, display = c("species", "site")) ## beetles is the response, lets plot those scores; sites first plot(bp.sc$site$X1[, 1], bp.sc$site$X1[, 2], type = "n", asp = 1) ## if you want labels then text(bp.sc$site$X1[, 1], bp.sc$site$X1[, 2], labels = rownames(bp.sc$site$X1), cex = 0.7) ## or just the points points(bp.sc$site$X1[, 1], bp.sc$site$X1[, 2], cex = 0.7) ## or we can plot the species with labels plot(bp.sc$species$U1[, 1], bp.sc$species$U1[, 2], type = "n", asp = 1) ## then draw species as labels text(bp.sc$species$U1[, 1], bp.sc$species$U1[, 2], labels = rownames(bp.sc$species$U1), cex = 0.5) Problem is, these are terribly crowded. A better solution might be to allow you the user to label the points. Here is a solution using identify() ## solution using identify() plot(bp.sc$species$U1[, 1], bp.sc$species$U1[, 2], asp = 1, cex = 0.5) identify(bp.sc$species$U1[, 1], bp.sc$species$U1[, 2], labels = rownames(bp.sc$species$U1), cex = 0.5, col = "red") ## click some points to label them, right click the plot window to end Note that if your want the predictor data set (in my example here these are the scores for plants), then switch the X1 for X2 or U1 for U2 in bp.sc$site$X1 or bp.sc$species$U1 - yes, I know this is not user friendly, but it matches the Matlab code from which cocorresp was ported, but will be changed in a future version of the package. Does this help? G -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.