Re: [R] Biplot for PCA using labdsv package

2010-04-09 Thread Jari Oksanen
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.
 
Dilys,

This seems to work:

m - pca(bryceveg)
stats:::biplot.princomp(m)

or, alternatively,

class(m) - c(class(m), princomp)
biplot(m)

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

__
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.


Re: [R] Biplot for PCA using labdsv package

2010-04-05 Thread Michael Denslow
Hi Dilys,

On Fri, Apr 2, 2010 at 3:08 AM, Dilys Vela dily...@gmail.com wrote:
 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.

It seems like you are mixing the pca function from package labdsv with
the biplot function from package stats. Is that correct? pca from
labdsv is a wrapper for prcomp but has a different output. For example
using the Bryce Data from labdsv:

# pca in labdsv
 str(pca(bryceveg))
List of 4
 $ scores  : num [1:160, 1:160] 0.304 -0.107 0.325 0.301 3.051 ...
  ..- attr(*, dimnames)=List of 2
  .. ..$ : chr [1:160] 50001 50002 50003 50004 ...
  .. ..$ : chr [1:160] PC1 PC2 PC3 PC4 ...
 $ loadings: num [1:169, 1:160] -0.00638 0.03989 0.85517 -0.05806 -0.03787 ...
  ..- attr(*, dimnames)=List of 2
  .. ..$ : chr [1:169] junost ameuta arcpat arttri ...
  .. ..$ : chr [1:160] PC1 PC2 PC3 PC4 ...
 $ sdev: num [1:160] 1.799 1.09 0.793 0.647 0.557 ...
 $ totdev  : num 9.24
 - attr(*, class)= chr pca

# prcomp from stats
 str(prcomp(bryceveg))
List of 5
 $ sdev: num [1:160] 1.799 1.09 0.793 0.647 0.557 ...
 $ rotation: num [1:169, 1:160] -0.00638 0.03989 0.85517 -0.05806 -0.03787 ...
  ..- attr(*, dimnames)=List of 2
  .. ..$ : chr [1:169] junost ameuta arcpat arttri ...
  .. ..$ : chr [1:160] PC1 PC2 PC3 PC4 ...
 $ center  : Named num [1:169] 0.0125 0.0813 1.1231 0.1531 0.1 ...
  ..- attr(*, names)= chr [1:169] junost ameuta arcpat arttri ...
 $ scale   : logi FALSE
 $ x   : num [1:160, 1:160] 0.304 -0.107 0.325 0.301 3.051 ...
  ..- attr(*, dimnames)=List of 2
  .. ..$ : chr [1:160] 50001 50002 50003 50004 ...
  .. ..$ : chr [1:160] PC1 PC2 PC3 PC4 ...
 - attr(*, class)= chr prcomp

biplot (or biplot.prcomp) is expecting something like the second example.
I am not sure if there is an equivalent function in labdsv so you may
wish to use prcomp directly. Either way if you provide the code you
used it will make it easier to sort out.

Hope this helps,
Michael

-- 
Michael Denslow

I.W. Carpenter Jr. Herbarium [BOON]
Department of Biology
Appalachian State University
Boone, North Carolina U.S.A.
-- AND --
Communications Manager
Southeast Regional Network of Expertise and Collections
sernec.org

36.214177, -81.681480 +/- 3103 meters

__
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.


[R] Biplot for PCA using labdsv package

2010-04-02 Thread Dilys Vela
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.

Thanks,

Dilys

[[alternative HTML version deleted]]

__
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.