title: R Normalize then plot two histograms together in R
body: <p>I realize there have been several posts for people asking how to plot two histograms together side by side (as in one plot with the bars next to each other) and overlaid in R and also on how to normalize data. Following the advice that I've found, I'm able to do one or the other, but not both operations.</p>
  
  <p>Here's the setup.
  I have two data frames of different lengths and would like to plot the volume of the objects in each df as a histogram. Eg how many in data frame 1 are between .1-.2 um^3 and compare it with how many in data frame 2 are between .1 and .2 um^3 and so on. Overlaid or Side by Side would be great to do this.</p>
  
  <p>Since there are more measurements in one data frame than the other, obviously I have to normalize, so I use:</p>
  
  <pre><code>read.csv(ctl)
  read.csv(exp)
  h1=hist(ctl$Volume....)
  h2=hist(exp$Volume....
  
  #to normalize#
  
  h1$density=h1$counts/sum(h1$counts)*100
  plot(h1,freq=FALSE....)
  h2$density=h2$counts/sum(h2$counts)*100
  plot(h2,freq=FALSE....)
  </code></pre>
  
  <p>Now I've been successful overlaying the un-normalized data using this method: <a href="http://www.r-bloggers.com/overlapping-histogram-in-r/" rel="noreferrer">http://www.r-bloggers.com/overlapping-histogram-in-r/</a> and also with this method: <a href="https://stackoverflow.com/questions/11193901/plotting-two-histograms-together">plotting two histograms together</a></p>
  
  <p>but I'm stuck when it comes to how to overlay normalized data</p>