title: Plot an ROC curve in R with ggplot2
body: <p>I have two variables (Condition1 &amp; Condition 2) for which I have calculated false alarm rates and hit rates and I would like to plot these on the same graph with separate curves for Condition1 and Condition 2. Both of these conditions have three points and both use the same false alarm rates. Here is what my data frame looks like:</p>
  
  <pre><code>measure &lt;- c('False_Alarm','False_Alarm','False_Alarm', 'Hit_Rate_Condition1',
   'Hit_Rate_Condition1','Hit_Rate_Condition1', 'Hit_Rate_Condition2','Hit_Rate_Condition2',
    'Hit_Rate_Condition2')
  point_on_curve&lt;- c(1, 2, 3, 1, 2, 3, 1, 2, 3)
  percentage &lt;- c(0.11, 0.1, 0.01, 0.80, 0.50, 0.20, 0.80, 0.55, 0.25)
  
  ROC_data &lt;- data.frame(measure,point_on_curve, percentage)
  </code></pre>
  
  <p>False alarms should go on the x axis, and hit rates should go on the y axis.
  Please note that I specifically am not interested in ROC packages such as ROCR, but rather I think it should be possible to plot this using just ggplot. </p>
  
  <p>Many thanks in advance!</p>
  
  <p>p.s. Just to show that I have at least been trying something and genuinely don't want to get stack exchange to do my PhD for me, I've tried  recasting the DF and separating the two to make two plots as so:</p>
  
  <pre><code> Condition_1 &lt;- dcast(ROC_data, point_on_curve ~ measure)
   Condition_1 &lt;- Condition_1[which(!Condition_1$measure == Hit_Rate_Condition2),]
  p &lt;- ggplot(data=Condition_1, aes(x=False_Alarm, y=Hit_Rate)) +     
    geom_point() +    
    stat_smooth(method = "lm", formula = y ~ splines::bs(x, 1), col = "red") +
    expand_limits(x = c(0, 1))
  </code></pre>
  
  <p>This results in some absurd line which isn't a smooth ROC (not what I need), and I would still need to combine the two.... in any case, there must be an easy way to make this plot (which I need to do another 18 times) with the original DF in one go...</p>
  
  <p>This is an example of how the curved line should be (I'm not looking for something aesthetically the same, just the same sort of curve!)
  <a href="https://i.stack.imgur.com/eGCXd.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eGCXd.jpg" alt="enter image description here"></a></p>