title: Error cannot rescale a constant/zero column to unit variance with prcomp
body: <p>I have a data set with 290 observations and 24475 features,
  I split the data set to train data set and test data set with this code:</p>
  
  <pre class="lang-r prettyprint-override"><code>set.seed(107)
  y &lt;- dim(data)[2]-1
  require(caret)
  inTrain &lt;- createDataPartition(y = data[, y],p = precent_of_partition,list = FALSE)
  training &lt;- data[ inTrain,]
  testing &lt;- data[-inTrain,]
  </code></pre>
  
  <p>when I try to perform pca on the train set: <code>pca.result &lt;- prcomp(expression_matrix, center = TRUE, scale. = TRUE)</code></p>
  
  <p>I get this error:</p>
  
  <blockquote>
    <p>Error in prcomp.default(expression_matrix, center = TRUE, scale. = TRUE) : 
    cannot rescale a constant/zero column to unit variance</p>
  </blockquote>
  
  <p>but if I perform pca on the all data set I dont get error at all and it works,</p>
  
  <p>can someone clarify what is hepping? how can I solve this problem?</p>