Guest User

Untitled

a guest
Apr 24th, 2018
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | None | 0 0
  1. #!/usr/bin/env Rscript
  2.  
  3. library(ggplot2)
  4. library(reshape2)
  5. library(pander)
  6.  
  7. data <- read.csv("results/results.csv", check.names=FALSE)
  8.  
  9. # Reorder columns for readability.
  10. col_order <- c("Least-squares slope", "Theil-Sen slope",
  11. "Mean", "Median of means",
  12. "Minimum of means", "Quartile 1 of means", "Quartile 3 of means")
  13. data <- data[, col_order]
  14.  
  15. molten <- melt(data)
  16.  
  17. # Assign categories to variables.
  18. molten$type <- factor(
  19. "This should never be visible",
  20. levels=c("Central tendency", "Regression", "Other", "This should never be visible"))
  21. molten <- within(molten, type[variable == "Least-squares slope" | variable == "Theil-Sen slope"] <- "Regression")
  22. molten <- within(molten, type[variable == "Mean" | variable == "Median of means"] <- "Central tendency")
  23. molten <- within(molten, type[variable == "Quartile 1 of means" | variable == "Quartile 3 of means" | variable == "Minimum of means"] <- "Other")
  24.  
  25. # Draw densities.
  26. plot <- ggplot(molten, aes(x=value, color=variable)) +
  27. geom_density(adjust=0.5) +
  28. labs(x="Time [s]", y="Number of benchmarks (smoothed)", color="") +
  29. facet_wrap("type", scales="fixed", ncol=1)
  30. ggsave("results/density.pdf", plot, device=cairo_pdf, width=8, height=6)
  31.  
  32. # Draw boxplots.
  33. plot <- ggplot(molten, aes(x=variable, y=value)) +
  34. geom_boxplot() +
  35. labs(x="Statistic", y="Time [s]") +
  36. theme(axis.text.x=element_text(angle=25, hjust=1))
  37. png(filename="results/boxplot.png", type="cairo", width=1100, height=1100, units="px", res=200)
  38. print(plot)
  39. dev.off()
  40.  
  41. # Data range as a single number (instead of vector of min and max).
  42. range_num <- function(data) {
  43. return(diff(range(data)))
  44. }
  45.  
  46. # Summarize the spread of the data in a table.
  47. df <- data.frame()
  48. df[ncol(data),] <- NA
  49. rownames(df) <- names(data)
  50. iqr_rel <- apply(data, 2, IQR) / apply(data, 2, median)
  51. df$`IQR/Median` <- sprintf("%.1f%%", unlist(iqr_rel * 100))
  52. range_rel <- apply(data, 2, range_num) / apply(data, 2, median)
  53. df$`Range/Median` <- sprintf("%.1f%%", unlist(range_rel * 100))
  54. table <- pandoc.table.return(
  55. df, style="rmarkdown", justify=c("right", "left", "left"), emphasize.rownames=FALSE)
  56. handle <- file("results/summary.md")
  57. writeLines(table, handle)
  58. close(handle)
Add Comment
Please, Sign In to add comment