Skip to content

Instantly share code, notes, and snippets.

@nicokosi
Last active August 29, 2015 13:56
Show Gist options
  • Save nicokosi/9089690 to your computer and use it in GitHub Desktop.
Save nicokosi/9089690 to your computer and use it in GitHub Desktop.
R code that generates graph for collinear detection, week 3 assigment from Coursera MOOC "Algoritms, part I" (https://www.coursera.org/course/algs4partI). N.B.: input CSV file contains this kind of data: "n,time,algo\n10,0.497,brute\n10,0.006,fast\n# etc...".
# R code that generates graph for collinear detection, week 3 assigment from Coursera MOOC "Algoritms, part I" (https://www.coursera.org/course/algs4partI). N.B.: input CSV file contains this kind of data: "n,time,algo\n10,0.497,brute\n10,0.006,fast\n# etc...".
library(ggplot2)
d <- read.csv("collinear-timings-brute-vs-fast.csv")
d$algo <- factor(d$algo)
levels(d$algo)[levels(d$algo)=="brute"] <- "Brute force"
levels(d$algo)[levels(d$algo)=="fast"] <- "Fast"
png("collinear-timings-brute-vs-fast.png")
ggplot(data=d, aes(x=n, y=time, group=algo, colour=algo)) + geom_line() + geom_point() + ggtitle("Collinear detection algorithms\ncf. https://www.coursera.org/course/algs4partI") + xlab("Number of points") + ylab("Duration in seconds") + scale_colour_hue("Algorithms")
dev.off()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment