[R] Biplot for PCA using labdsv package

Jari Oksanen jari.oksanen at oulu.fi
Fri Apr 9 09:20:02 CEST 2010

Dilys Vela <dilysvd <at> gmail.com> writes:

> Hi everyone,
> I am doing PCA with labdsv package. I was trying to create a biplot graphs
> in order to observe arrows related to my variables. However when I run the
> script for this graph, the console just keep saying:
> *Error in nrow(y) : element 1 is empty;
>    the part of the args list of 'dim' being evaluated was:
>    (x)*
> could please someone tell me what this means? what i am doing wrong? I will
> really appreciate any suggestions and help.

This seems to work:

m <- pca(bryceveg)

or, alternatively,

class(m) <- c(class(m), "princomp")

Explanation: the pca() function in labdsv returns an object that resembles a lot
the princomp() result (although Dave uses prcomp for actual calculation), and
you can use methods of princomp objects to display the results. However, the
output does not show this inheritance in its class(), and therefore you can
either explicitly use princomp methods or set the class to inherit from
princomp. Since biplot.princomp is not exported, you must use
stats:::biplot.princomp notation to access the biplot() function if you do not
set the class.

Cheers, Jari Oksanen

More information about the R-help mailing list