Report function outputs in R programming

0 votes

I'm using the pcaPP package in R and i have the following code:


x  <-  rbind(rmvnorm(200,  rep(0,  6),  diag(c(5,  rep(1,5)))),
             rmvnorm(  15,  c(0,  rep(20,  5)),  diag(rep(1,  6))))

pc  <-  PCAproj(x)

This is the documentation for the output value of the PCAproj function:

The function returns a list of class '"princomp"', i.e. a list
similar to the output of the function 'princomp'.
    sdev: the (robust) standard deviations of the principal components.

loadings: the matrix of variable loadings (i.e., a matrix whose columns 
          contain the eigen- vectors). This is of class "loadings":
          see loadings for its print method.

  center: the means that were subtracted.

   scale: the scalings applied to each variable.

   n.obs: the number of observations.

  scores: if 'scores = TRUE', the scores of the supplied data on the
          principal components.

    call: the matched call.

My question is how can I return the other outputs of PCAproj like sdev and then report those in R-studio?

Jan 14, 2019 in Data Analytics by Tyrion anex
• 8,660 points

1 answer to this question.

0 votes

In your case, you've stored the output in pc.

Use the interactive mode and type pc$sdev and pc$loading to see their outputs:

> pc$sdev
  Comp.1   Comp.2
2.425413 1.346727

> pc$loadings

   Comp.1 Comp.2
V1  0.972  0.153
V2 -0.201  0.447
V3        -0.130
V4        -0.211
V5         0.739
V6 -0.109  0.412

               Comp.1 Comp.2
SS loadings     1.000  1.000
Proportion Var  0.167  0.167
Cumulative Var  0.167  0.333
answered Jan 14, 2019 by Sophie may
• 10,550 points

Related Questions In Data Analytics

0 votes
2 answers

R function for finding the index of an element in a vector?

The function match works on vectors : x <- sample(1:10) x # ...READ MORE

answered Dec 11, 2020 in Data Analytics by Rajiv
• 8,880 points
+1 vote
2 answers

Which function can I use to clear the console in R and RStudio ?

Description                   Windows & Linux           Mac Clear console                      Ctrl+L ...READ MORE

answered Apr 17, 2018 in Data Analytics by anonymous
0 votes
1 answer

Why should I use set.seed function() in R?

set.seed(seed) Set the seed of R‘s random number ...READ MORE

answered Apr 23, 2018 in Data Analytics by zombie
• 3,790 points
0 votes
1 answer

Python equivalent to replace function in R

There is actually a replace function in ...READ MORE

answered May 30, 2018 in Data Analytics by Bharani
• 4,620 points
+10 votes
3 answers

Which is a better initiative to learn data science: Python or R?

Well it truly depends on your requirement, If ...READ MORE

answered Aug 8, 2018 in Data Analytics by Abhi
• 3,720 points
+1 vote
2 answers
0 votes
1 answer

R programming logic

Use gsub to match the substring that we want ...READ MORE

answered Nov 16, 2018 in Data Analytics by Maverick
• 10,840 points
0 votes
1 answer
+1 vote
1 answer

Can we have an if loop inside a for loop in R programming?

You're If loop doesn't have any condition ...READ MORE

answered Dec 21, 2018 in Data Analytics by Sophie may
• 10,550 points
0 votes
1 answer

R Programming error in 'fert'

You're using a factor: fert <- factor(c(50,20,10,10,20,50)) levels(fert) #[1] ...READ MORE

answered Dec 27, 2018 in Data Analytics by Sophie may
• 10,550 points