title: use sm.density.compare to plot density functions, draw lines for each mode and get the mode values back
body: <p>I have got dive depth data for seabirds over several trips and I would like to find the modes for each trip, plot the density functions and a line corresponding to the modes. So far, here's the code I have been using:</p>
  
  <pre><code>maxdepths&lt;-read.csv("maximum_depths.csv", header=T)
  maxdepths_ind21&lt;-maxdepths[maxdepths$bird=="21",]
  # create value labels 
  trip.f &lt;- factor(maxdepths_ind21$trip, levels= c(21.1,21.2,21.3,21.4,21.5,21.6,21.7,21.8),
                  labels = c("Trip1", "Trip2", "Trip3", "Trip4", "Trip5", "Trip6", "Trip7", "Trip8")) 
  
  # plot densities 
  z&lt;-sm.density.compare(maxdepths_ind21$maxdep, maxdepths_ind21$trip,model="equal") 
  
  sm.density.compare(maxdepths_ind21$maxdep, maxdepths_ind21$trip, xlab="Maximum depth (m)", xlim=c(0, 90), axes=F)
  title(main="Maximum dive depth by trip, individu 21")
  axis(side = 1, at = c(0,5,10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90))
  axis(side = 2, at = c(0,0.01,0.02,0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 1))
  
  # add legend via mouse click
  colfill&lt;-c(2:(2+length(levels(trip.f)))) 
  legend(locator(1), levels(trip.f), fill=colfill)
  </code></pre>
  
  <p>The result looks good, ie I've got one curve per trip with different colours/line types per trip.</p>
  
  <p>I now would like to draw lines for each trip when the density functions are maximized, as well as find those values. I am aware of this thread
  <a href="https://stackoverflow.com/questions/31252058/r-getting-data-instead-of-plot-back-from-sm-density-compare">R: getting data (instead of plot) back from sm.density.compare</a> 
  and I have tried assigning the result of sm.density.compare to an object and then calling it, like so:</p>
  
  <pre><code>z&lt;-sm.density.compare(maxdepths_ind21$maxdep, maxdepths_ind21$trip,model="equal") 
  z
  </code></pre>
  
  <p>I was looking for the values of the modes within this output but I got confused by all the values that are returned. 
  Any help would be much appreciated!
  TIA</p>