title: Error encountered: Plotting PCA figure via ggbiplot
body: <p>I am very new to R and trying to plot a PCA figure of my data using ggbiplot. So please bear with me if my question does not make any senses to you. Basically, I was following the tutorial I found <a href="http://www.r-bloggers.com/computing-and-visualizing-pca-in-r/" rel="nofollow">here</a>, except I was using my own data set.</p>
  
  <p>Everything was fine until I wish to use the code below to plot a figure:</p>
  
  <pre><code>g &lt;- ggbiplot(ir.pca, obs.scale = 1, var.scale = 1, 
                    groups = ir.ppm, ellipse = TRUE, 
                    circle = TRUE)
  </code></pre>
  
  <p>Then, I encountered an error stating : <strong><em>Error in names(ell)[1:2] &lt;- c("xvar", "yvar") : 
    'names' attribute [2] must be the same length as the vector [0]</em></strong></p>
  
  <p>After that, I edited my code and using the default setting for <strong><em>groups =</em></strong>, which should be = NULL as I recall. </p>
  
  <pre><code>g &lt;- ggbiplot(ir.pca, obs.scale = 1, var.scale = 1, 
                    groups = ir.ppm, ellipse = TRUE, 
                    circle = TRUE) `
  </code></pre>
  
  <p>With the edited code, I did able to plot the PCA figure but It cannot categorize the observations into different groups as I desired. Although I still does not know the meaning of the error: Error in names(ell)[1:2] &lt;- c("xvar", "yvar") : 'names' attribute [2] must be the same length as the vector [0] , I do suspect that it may have something to do with my factor <strong><em>ir.ppm</em></strong>.</p>
  
  <p>Here are all the code I have used before I have encountered the error.</p>
  
  <pre><code>ppm3 = read.csv("normalize_GasPhase_heatmap_no_ID_transpose.csv", header = TRUE, row.names = 1)
  ppm3_1 &lt;- ppm3[,1:30]
  ir.ppm &lt;- ppm3[,31]
  ir.pca &lt;- prcomp(ppm3_1, center = TRUE, scale. = TRUE)
  library(ggbiplot)
  g &lt;- ggbiplot(ir.pca, obs.scale = 1, var.scale = 1, groups = ir.ppm, ellipse = TRUE, circle = TRUE)
  </code></pre>
  
  <p>In total, I have 6 observations and 31 variables in my raw data ppm3. </p>
  
  <p>I have been browsing some questions related to plotting PCA figure with ggbiplot in stackoverflow, but it seems not much people encountered the same problem as I did. I would really appreciate if anyone can offer me some help. Thank you.</p>