title: Error in svd(x, nu = 0) : 0 extent dimensions
body: <p>I am trying to do PCA on data frame with 5000 columns and 30 rows</p>
  
  <pre><code>Sample &lt;- read.table(file.choose(), header=F,sep="\t")
  Sample.scaled &lt;- data.frame(apply(Sample,2,scale))
  pca.Sample &lt;- prcomp(Sample.scaled,retx=TRUE)`
  </code></pre>
  
  <p>Got the error</p>
  
  <pre><code>Error in svd(x, nu = 0) : infinite or missing values in 'x'
  
  sum(is.na(Sample))
  [1] 0
  
  sum(is.na(Sample.scaled))
  [1] 90
  </code></pre>
  
  <p>Tried to ignore all na values by using the following </p>
  
  <pre><code>pca.Sample &lt;- prcomp(na.omit(Sample.scaled),retx=TRUE)
  </code></pre>
  
  <p>Which gives the following error</p>
  
  <pre><code>Error in svd(x, nu = 0) : 0 extent dimensions
  </code></pre>
  
  <p>There were reports that na.action requires formula to be given and hence tried the below</p>
  
  <pre><code>pca.Sample &lt;- prcomp(~.,center=TRUE,scale=TRUE,Sample, na.action=na.omit)
  </code></pre>
  
  <p>Now getting the following error</p>
  
  <pre><code>Error in prcomp.default(x, ...) :
    cannot rescale a constant/zero column to unit variance
  </code></pre>
  
  <p>Think that the problem might be because "One of my data columns is constant.  The variance of a constant is 0, and scaling would then divide by 0, which is impossible."</p>
  
  <p>But not sure on how to tackle this. Any help much appreciated ....</p>