title: PCA on transposed data
body: <p>I am using R to do some PCA analysis. Everything was working fine until it occurred to me that I should be dealing with the transpose of my data set. However when I tried to do PCA on the transposed data set I could not get it to work out!</p>
  
  <pre><code>&gt; sum(is.na(data_t))
  [1] 1367
  &gt; dim(data_t)
  [1]  599 9505
  &gt; data_t[1:4,1:4]
                               2'-PDE    7A5      A1BG     A2M
  TCGA.A1.A0SD.01A.11R.A115.07  0.0153750 2.4105 0.9493333 0.24200
  TCGA.A1.A0SE.01A.11R.A084.07  0.4669375 0.3635 0.2798333 1.03850
  TCGA.A1.A0SH.01A.11R.A084.07 -0.0295625 1.8550 0.7486667 1.16050
  TCGA.A1.A0SJ.01A.11R.A084.07  0.7919375 1.4080 0.7500000 1.67775
  
  &gt; pca2&lt;-princomp(~.,data=data_t, na.action=na.omit)
   Error in `[.data.frame`(mf, , x) : undefined columns selected
  
  &gt; pca2&lt;-princomp(data_t, na.action=na.omit)
   Error in princomp.default(data_t, na.action = na.omit) : 
    'princomp' can only be used with more units than variables
  </code></pre>
  
  <p>Turns out that you cannot use princomp if you have more variables than units. But you can use prcomp (see <a href="https://stackoverflow.com/questions/5686940/r-princomp-can-only-be-used-with-more-units-than-variables">R - &#39;princomp&#39; can only be used with more units than variables</a>) but I still get errors with that!</p>
  
  <pre><code>&gt; pca2&lt;-prcomp(data_t,na.action=na.omit)
   Error in svd(x, nu = 0) : infinite or missing values in 'x'
  
  &gt; pca2&lt;-prcomp(~ ., data=data_t, na.action=na.omit, scale=TRUE)
   Error in `[.data.frame`(mf, , x) : undefined columns selected
  </code></pre>