0

Not sure if this is due to my limited knowledge of R or just plain impossible but here is my problem.

I have a dataset made of a bunch of chemical signatures for a number of samples. In order to find possible correlations, I ran a PCA and now I'd need to plot each sample (once projected onto each components) in function of its sample number instead of having a biplot with the two main components (yes I know it's weird, but I really need to do it this way).

I'll post a dummy dataset and the way I'm running the PCA

depth<-c(1:1000)
Na<-runif(1000, min=50, max=100)
K<-runif(1000, min=0, max=10)
Mg<-runif(1000, min=5, max=20)
Ca<-runif(1000, min=5, max=20)
Cl<-runif(1000, min=50, max=50)
NO3<-runif(1000, min=10, max=75)
SO4<-runif(1000, min=50, max=200)

data<-data.frame(depth, Na;K,Mg,Ca,Cl,NO3,SO4)
GV7.pca<-prcomp(data[,c(2:8)])

And now I'm stuck. I need to plot them and see for each sample, essentially, its "value" once projected onto each components and then see the variability in function of the depth of the sample: normally I would use ggbiplot(GV7.pca) to obtain a quick graphical representation of my data, but that only considers the first two major components (and I'm interested in some less significant ones) and the number of data I have make so that it's almost impossible to see anything.

Any idea?

Werner Hertzog
  • 2,002
  • 3
  • 24
  • 36
Raffaello Nardin
  • 151
  • 2
  • 11
  • 2
    You can find all the generated components in `GV7.pca$x`, however I couldn't really picture what you want to plot, can you explain maybe what should be on the x-axis and what should be on the y-axis, or perhaps post an example of the plot you'd like to have – DS_UNI Nov 09 '20 at 11:24
  • 2
    Generally you use a screeplot to see the most important components, that (hoping) are less than the variable (it's a spatial reduction model, i.e. Rn --> Rm with m< n). Maybe it could be helpful to know your goals. Technically you can also do a biplot for each combination of principal components, but I do not know how much sense makes without knowing your goals. – s__ Nov 09 '20 at 14:02

0 Answers0