title: Adding different vertical lines on facets ggplot2
body: <p>I am quite a newbie to RStudio and I am having problems adding <em>different</em> vertical lines on each of my two facets using facet_wrap</p>
  
  <p>Here is what I thought:</p>
  
  <pre><code>library(ggplot2)
  
  g &lt;- ggplot(dat, aes(x=index, na.rm= TRUE))
  
  d &lt;- g+ geom_density() + facet_wrap(~gender)
  
  vline.data &lt;- data.frame(z = c(2.36,2.48),gender = c("Female","Male")) 
  
  d1 &lt;- d + geom_vline(aes(xintercept = z),vline.data)
  </code></pre>
  
  <p>But it adds the same two lines to each facet -  what would you reckon is the problem? I have thought of somehow splitting the facets into two separate data frames, but I have no idea how to go on about it. </p>
  
  <p>P.S The x-axis (the index) goes from 1 to 4.</p>
  
  <p>Thank you in advance.</p>
  
  <pre><code>        index  &lt;-  c(NA, NA, 4, 4, 4, NA, NA, NA, NA, 2, 2, 2, 2, 2, 3, 3, 3, 3, 
          3, NA, 3, NA, NA, 3, 4, 4, 4, 4, 4, 3, 4, 3, 4, 3, NA, 4, 2, 
          4, 4, 2, 2, NA, 2, 3, 3, 2, 2, NA, NA, 2)
  
         gender &lt;-  c("Female", "Female", "Male", "Male", "Male", "Female", "Female", 
          "Male", "Female", "Male", "Female", "Male", "Female", "Male", 
          "Male", "Female", "Female", "Female", "Male", "Female", "Female", 
          "Male", "Male", "Female", "Female", "Female", "Male", "Male", 
          "Female", "Female", "Male", "Female", "Female", "Female", "Male", 
          "Male", "Female", "Male", "Male", "Female", "Female", "Male", 
          "Male", "Female", "Female", "Male", "Male", "Male", "Male", "Male")
  </code></pre>
  
  <p>Using the code and data above I get <a href="https://i.stack.imgur.com/vE9y1.png" rel="nofollow noreferrer">this plot</a></p>