2011年5月26日星期四

R code - manipulating biplot

require(vegan)
require(labdsv)
data(dune)
data(dune.env)

## Indicators of Management type
set.seed(38)
inds<- with(dune.env, indval(dune, Management))

## ordinate
dune.pca<- rda(dune, scale = TRUE)

## exract scores you want to plot presume species and sites
dune.site<- scores(dune.pca, display = "sites", scaling = 3)
dune.spp<- scores(dune.pca, display = "species",
                     scaling = 3)[inds$pval<= 0.05, ]

## plot
plot(dune.pca, display = c("sites","species"), type = "n",
      scaling = 3)
points(dune.site)
arrows(0, 0, dune.spp[,1], dune.spp[,2], col = "red", length = 0.05)
lab.xloc<- dune.spp[,1] * 1.2
lab.yloc<- dune.spp[,2] * 1.2
text(lab.xloc, lab.yloc, rownames(dune.spp), col = "red", cex = 0.8)

没有评论:

发表评论