title: Identify spikes/peaks in density plot by group
body: <p><a href="https://i.stack.imgur.com/aNNQb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aNNQb.png" alt="Image"></a></p>
  
  <p>I created a density plot with <code>ggplot2</code> package for <code>R</code>. I would like to identify the spikes/peaks in the plot which occur between 0.01 and 0.02. There are too many legends to pick it out so I deleted all legends. I tried to filter my data out to find most number of rows that a group has between 0.01 and 0.02. Then I filtered out the selected group to see whether the spike/peak is gone but no, it is there plotted still. Can you suggest a way to identify these spikes/peaks in these plots?</p>
  
  <p>Here is some code : </p>
  
  <pre><code>ggplot(NumofHitsnormalized, aes(NumofHits_norm, fill = name)) + geom_density(alpha=0.2) + theme(legend.position="none") + xlim(0.0 , 0.15) 
  
  ## To filter out the data that is in the range of first spike
  test &lt;- NumofHitsnormalized[which(NumofHitsnormalized$NumofHits_norm &gt; 0.01 &amp; NumofHitsnormalized$NumofHits_norm &lt;0.02),] 
  
  ## To figure it out which group (name column) has the most number of rows ##thus I thought maybe I could get the data that lead to spike
  testMatrix &lt;- matrix(ncol=2, nrow= length(unique(test$name))) 
  for (i in 1:length(unique(test$name))){ 
  testMatrix[i,1] &lt;- unique(test$name)[i] 
  testMatrix[i,2] &lt;- nrow(unique(test$name)[i])} 
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/mLIwZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mLIwZ.png" alt="extremeValues"></a></p>
  
  <p>Konrad, </p>
  
  <p>This is the new plot made after I filtered my data out with extremevalues package. There are new peaks and they are located at different intervals and it also says 96% of the initial groups have data in the new plot (though number of rows in filtered data reduced to 0.023% percent of the initial dataset) so I cant identify which peaks belong to which groups. </p>