Plot also Sensitivity, Balanced Accuracy and use ggplot

Change-Id: I23fa3680620d14df184b1ec879e22108991fb5be
diff --git a/R/idiomclassification_mk_pf.R b/R/idiomclassification_mk_pf.R
index f6f40e9..5209c75 100644
--- a/R/idiomclassification_mk_pf.R
+++ b/R/idiomclassification_mk_pf.R
@@ -105,18 +105,16 @@
 # Analysing tradeoff between Fscore, Recall, Precision for various cutoffs
 # full range from precision almost 100% to recall almost 100%
 rf_classifier = randomForest(fmla, train, importance=TRUE)
-cvalues<-c()
+cvalues<-tibble()
 for (c in c(0.001, seq(from=0.05,to=0.5,by=0.025))) {
   prediction_for_table <- predict(rf_classifier, test %>% select(-CO_IDIOM), cutoff = c(c, 1-c))
   conf<-confusionMatrix(prediction_for_table, test$CO_IDIOM, positive = "idiom")
-  cvalues<-rbind(cvalues,c(c,conf$byClass))
+  cvalues <-bind_rows(cvalues, c(cutoff=c, conf$byClass))
 }
-
-plot(cvalues[,1],cvalues[,"F1"],type = "o",col = "green", xlab = "Cutoff", ylab = "F1",ylim=c(0,1),
-     main = "FScore, Recall, Precision")
-lines(cvalues[,1],cvalues[,"Recall"], type = "o", col = "blue")
-lines(cvalues[,1],cvalues[,"Precision"],type="o", col="red")
-legend("bottomleft",legend=c("FScore","Recall","Precision"),col=c("green","blue","red"),pch=c(1,1,1),lty=c(1,1,1))
+cvalues %>%
+  select(c("cutoff", "Recall", "Precision", "F1", "Specificity", "Balanced Accuracy")) %>%
+  pivot_longer(!cutoff, names_to=c("measure")) %>%
+  ggplot(aes(cutoff, value, colour=measure)) + geom_line()
 
 # Using estimates by random forest on entire dataset