title: Using factor values in PCA Analysis (using prcomp)
body: <p>I am trying to figure out how I can incorporate the factor/levels into my PCA analysis. Suppose I have the following:</p>
  
  <pre><code>&gt; df &lt;- data.frame(col1=c("A", "B", "C", "D"), col2=c(1, 2, 3, 4))
  &gt; str(df)
  'data.frame':   4 obs. of  2 variables:
   $ col1: Factor w/ 4 levels "A","B","C","D": 1 2 3 4
   $ col2: num  1 2 3 4
  </code></pre>
  
  <p>Theoretically df[,"col1"] is numeric internally in the df (since it is a factor) so I should be able to use its factor values for PCA analysis. But I can't seem to figure out how I can do it:</p>
  
  <pre><code>&gt; prcomp(df, center=T, scale. = T)
  Error in colMeans(x, na.rm = TRUE) : 'x' must be numeric
  </code></pre>
  
  <p>How can I include <code>col1</code> in my PCA analysis? Is there another PCA function I should be using?</p>