title: Visualisation of principal components (PC)
body: <p>I am using <code>ggplot2</code> in R to produce the plot from the code:  </p>
  
  <p>final_flights &lt;- augment(flights_model, flights_tbl) %>% collect()'
  <code>final_flights</code></p>
  
  <pre><code># A tibble: 327,346 x 22
      year month   day dep_time sched_dep_time dep_delay arr_time sched_arr_time
     &lt;int&gt; &lt;int&gt; &lt;int&gt;    &lt;int&gt;          &lt;int&gt;     &lt;dbl&gt;    &lt;int&gt;          &lt;int&gt;
   1  2013     1     1      517            515         2      830            819
   2  2013     1     1      533            529         4      850            830
   3  2013     1     1      542            540         2      923            850
   4  2013     1     1      544            545        -1     1004           1022
   5  2013     1     1      554            600        -6      812            837
   6  2013     1     1      554            558        -4      740            728
   7  2013     1     1      555            600        -5      913            854
   8  2013     1     1      557            600        -3      709            723
   9  2013     1     1      557            600        -3      838            846
  10  2013     1     1      558            600        -2      753            745
  # ... with 327,336 more rows, and 14 more variables: arr_delay &lt;dbl&gt;,
  #   carrier &lt;chr&gt;, flight &lt;int&gt;, tailnum &lt;chr&gt;, origin &lt;chr&gt;, dest &lt;chr&gt;,
  #   air_time &lt;dbl&gt;, distance &lt;dbl&gt;, hour &lt;dbl&gt;, minute &lt;dbl&gt;, time_hour &lt;dttm&gt;,
  #   PC1 &lt;dbl&gt;, PC2 &lt;dbl&gt;, PC3 &lt;dbl&gt;
  </code></pre>
  
  <p>I have tried already:</p>
  
  <pre><code>    ggplot(final_flights, aes(PC1, PC2)) +   
        geom_point(aes(colour=air_time))
  
  
      ggplot(final_flights, aes(PC1, PC2, PC3))+ 
        geom_point(aes(colour=air_time, distance, dep_time))
  
      ml_predict(kmeans_model) %&gt;%
        collect() %&gt;%
        ggplot(aes(air_time, distance, dep_time)) +
        geom_point(aes(air_time, distance, dep_time, col = factor(prediction+1)),
       size=2, alpha=0.5)+
       geom_point(data=kmeans_model$k, aes(air_time, distance, dep_time),
        pch='x', size=12)+
        scale_color_discrete(name="Predicted cluster")
  
  &gt; Warning: Ignoring unknown aesthetics:  Warning: Ignoring unknown
  &gt; aesthetics:  Error: Column 3 must be named.
  </code></pre>
  
  <p>I want to produce the ggplot model with two principal components, which variable explains the clustering in the data</p>