title: How create cluster plots for large datasets in R
body: <p>I use the <a href="https://stat.ethz.ch/R-manual/R-devel/library/cluster/html/clara.html" rel="nofollow noreferrer">CLARA algorithm</a> from Kaufman and Rousseeuw to cluster a large dataset with <strong>N > 8*10^6</strong> in R. The implementation of the algorithm itself allows the user to control execution time by e.g. limiting the samplesize to <strong>n=100</strong>.</p>
  
  <p>However it seems that the use of the <code>plot()</code> function in R includes all data-objects to the plot which results in a very large processing time and very crowded plots (see the reproducible example below). </p>
  
  <p>In theory it should be possible to only plot the best sample from <code>CLARA</code> instead of <code>N</code>. Is there an implementation for this or how can I work around this issue?</p>
  
  <pre><code>## generate 2.5 mio objects, divided into 2 clusters.
  x &lt;- rbind(cbind(rnorm(10^6,0,0.5), rnorm(10^6,0,0.5)),
             cbind(rnorm(1.5*10^6,5,0.5), rnorm(1.5*10^6,5,0.5)))
  
  library("cluster")
  # get clusters solution
  clara.x&lt;-clara(x,k=2,sampsize = 100)
  # see medoids
  clara.x$medoids
  
  # plot the cluster solution
  plot(clara.x) # takes long time. creates crowded plot
  clusplot(clara.x) # did not finish
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/NocAB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NocAB.png" alt="enter image description here"></a></p>