[R] vegan capscale 'subscript out of bounds' error

Jari Oksanen jari.oksanen at oulu.fi
Sat Jul 13 11:52:12 CEST 2013

Zhao Jin <zj29 <at> cornell.edu> writes:

> I am using the capscale function in vegan_2.0-7 to do a constrained
> principal coordinates analysis, and I kept getting the following error
> message:
> Error in Y.r[, oo, drop = FALSE] : subscript out of bounds
> I googled but I couldn't find an answer. Could anyone tell me why this
> error msg and what to do?
> Here is the command I used:
> mod=capscale(as.dist(dist)~mydataset$Var1+Condition(mydataset$Var2))
> My dataset looks like the output of column-binding the 'varespec' and
> 'varechem' datasets, and has 92 rows and about 3500 columns. I also fed
> capscale a similarity matrix in the formula.

Dear Zhao Jin,

This is irreproducible. I have tried several ways of giving wrong data or 
definition to capscale() and have been able to generate several different 
error messages, but not this one. We need more hints. 

Moreover, if 'dist' are distances (dissimilarities), you do not need as.dist() 
for them, and the formula takes a 'data' argument, so that you can write:

capscale(dist ~ Var1 + Condition(Var2), mydataset)

I would start at looking how 'dist' and 'mydataset' look like, and what are 
'Var1' and 'Var2'.

Cheers, Jari Oksanen

More information about the R-help mailing list