[R] Redundancy canonical analysis plot problem in 3D using VEGAN

Thomas.Rousseaubeaumier at UQTR.CA Thomas.Rousseaubeaumier at UQTR.CA
Sat Oct 29 20:57:28 CEST 2011


   Hi Guys,

First, English is not my native language so sorry if the question is

too difficult to understand. I can rephrase it if necessary.

I have 32-bit Windows Xp SP3, i use R version 2.12.0 (2010-10-15),
and
the question is about Redundancy canonical analysis  plot problem in

3D using VEGAN, RGL, SCATTERPLOT3D and SFSMISC.

I noticed the following  code to explain as clearly as possible the
problems encountered.

I am not able to add " species scores " from RDA results in 3D plot
like i can in 2D plot.

With the code i used , i get errors like ;

ERROR dans t$sites : $ operator is invalid for atomic vectors,

Erreur dans match.arg (display, items) : 'arg' should be one of
“xyz.convert”, “points3d”, “plane3d”, “box3d”, “points”, “arrows”

I saw that I can use other functions, but it is impossible to extract

the 3D scores ( and add species to 3d plot ), Other fonctions works
but, add elements in a 2D space.

How can I add the "species scores" (sites and arrows are added
correctly) to the 3D plot as with the 2D plot.

Thank you for your help,

Sincerely,

Thomas
University of Quebec at Trois-Rivieres , Canada
Environmental science MSC student.
rousseat at uqtr.ca, thomasbeaumier at hotmail.com

Here is the noticed code I used;

----- CODE ----------------

# Load library

library(vegan)
library(rgl)
library(scatterplot3d)
library(sfsmisc)

# Import data
ALLMAS <- read.table("C:/data.txt", header=TRUE, sep="",
na.strings="NA", dec=".", strip.white=TRUE

# Define var.

X <-ALLMAS[,c(10,14,15,16,18,19,22)] # env. (7) var.

Y <-ALLMAS[,c(9,3:6)]       # y. (4) var

Z <-ALLMAS[,c(25)]     # Z.  (1) var covariate

ENVIESRDA <-rda(Y,X,Z)     # Redundancy canonical analysis

pl <- ordiplot3d(ENVIESRDA, angle=15, type="n") # Get $Points (1:2) ,

get $arrows (1:2)

text(pl, "arrows", col="blue", pos=3, cex = 1) # Text env. var in
plot
text(pl, "points", col="red", pos=1, cex = 0.5) # Point "sites"
(y.var) in plot

text(pl, "species", col="blue", cex=0.8) # Text " species " in plot ,

#     I get the following error message:
#    Erreur dans match.arg(display, items) :
#     'arg' should be one of “xyz.convert”, “points3d”, “plane3d”,
“box3d”, “points”, “arrows”
#    I saw that I can use other functions, but it is impossible to
extract the 3D scores. Other features add elements in a 2D space.
#     Then I try the following code, which works well in 2D when I
extract the summary of the results of the RDA.

t <-summary(ENVIESRDA,scal=2) # t <-summary(pl,scal=2) ????

#         I get ;

# Length Class  Mode   
# xyz.convert        1     -none- function
# points3d            1     -none- function
# plane3d              1     -none- function
# box3d                1     -none- function
# points              48     -none- numeric
# arrows             14     -none- numeric

# Points = sites but where is " species scores " ?

X =t$sites[,1] # ERROR dans t$sites : $ operator is invalid for
atomic vectors
Y =t$sites[,2]
t$sites

summary(ENVIESRDA, step=1000, perm.max=1000) # Summary

anova(ENVIESRDA, step=1000, perm.max=1000) # Anova

# Draw arrows to connect the "sites" with each other before / after
study.

# But I can't get the new coordinates of 3D graphics using the
function summary.

stn2= p.arrows(X[1],Y[1], X[13],Y[13],fill="red",width=1)
stn3= p.arrows(X[2],Y[2], X[14],Y[14],fill="yellow",width=1)
stn4= p.arrows(X[3],Y[3], X[15],Y[15],fill="yellow",width=1)
stn5= p.arrows(X[4],Y[4], X[16],Y[16],fill="red",width=1)
stn6= p.arrows(X[5],Y[5], X[17],Y[17],fill="yellow",width=1)
stn7= p.arrows(X[6],Y[6], X[18],Y[18],fill="red",width=1)
stn9= p.arrows(X[7],Y[7], X[19],Y[19],fill="yellow",width=1)
stn10= p.arrows(X[8],Y[8], X[20],Y[20],fill="yellow",width=1)
stn11= p.arrows(X[9],Y[9], X[21],Y[21],fill="red",width=1)
stn12= p.arrows(X[10],Y[10], X[22],Y[22],fill="yellow",width=1)
stn13= p.arrows(X[11],Y[11], X[23],Y[23],fill="red",width=1)
stn18= p.arrows(X[12],Y[12], X[24],Y[24],fill="red",width=1)  
stn19= p.arrows(X[13],Y[13], X[25],Y[25],fill="red",width=1)

#     END

-------------------------------------------------
Courriel expédié via https://courriel.uqtr.ca



More information about the R-help mailing list