title: retrieving observation scores for each Principal Component in R
body: <p>I performed Principal Component Analysis on a data frame to reduce the number of predictors in my linear regression analysis. </p>
  
  <pre><code>pr.out = prcomp(df, scale=TRUE)
  pr.var = pr.out$sdev^2
  pve = pr.var/sum(pr.var)
  </code></pre>
  
  <p>Having done that, I would like to substitute the old variables in my data frame with the first few Principal Components that explain the greatest proportion of variance. But, for the life of me, I cannot find the vector of observations for each Principal Component (i.e. the PC1 score for each data point). Do you know how I can access them? I tried <code>pr.out$PC1</code> for example, but that returns <code>NULL</code>.</p>