Update charts to account for new datafile/charts folders
This commit is contained in:
@@ -1,21 +1,28 @@
|
||||
library(ggplot2)
|
||||
library(ggalluvial)
|
||||
|
||||
# Usage: Rscript combined_comparion.r exp_abspath1 exp_abspath2 ...
|
||||
# Usage: Rscript combined_sankey.r exp1 exp2 queries_dir charts_dir [faults_file]
|
||||
|
||||
args <- commandArgs(trailingOnly = TRUE)
|
||||
argc <- length(args)
|
||||
|
||||
if (argc < 2 || argc > 3) {
|
||||
print("Expecting two or three arguments: exp1 exp2 [faults_file]")
|
||||
if (argc < 4 || argc > 5) {
|
||||
print(paste(
|
||||
"Expecting four or five arguments:",
|
||||
"exp1 exp2 queries_dir charts_dir [faults_file]"
|
||||
))
|
||||
stop()
|
||||
}
|
||||
|
||||
faults_file <- if (argc == 3) args[3] else "faults.csv"
|
||||
faults_file <- if (argc == 5) args[5] else "faults.csv"
|
||||
suffix <- gsub("^faults|\\.csv$", "", faults_file)
|
||||
|
||||
for (experiment in args[1:2]) {
|
||||
datafile <- file.path(experiment, faults_file)
|
||||
experiments <- args[1:2]
|
||||
queries_dir <- args[3]
|
||||
charts_dir <- args[4]
|
||||
|
||||
for (experiment in experiments) {
|
||||
datafile <- file.path(queries_dir, paste0(experiment, "_", faults_file))
|
||||
if (!file.exists(datafile)) {
|
||||
print(paste("Input file", datafile, "is missing"))
|
||||
stop()
|
||||
@@ -33,13 +40,13 @@ resulttype_labels <- c(
|
||||
)
|
||||
|
||||
# Read data
|
||||
datafile1 <- file.path(args[1], faults_file)
|
||||
datafile1 <- file.path(queries_dir, paste0(experiments[1], "_", faults_file))
|
||||
data1 <- readr::read_csv(datafile1)
|
||||
data1$fault_address <- strtoi(data1$fault_address)
|
||||
data1$resulttype <- resulttype_labels[data1$resulttype]
|
||||
# tibble::glimpse(data1)
|
||||
|
||||
datafile2 <- file.path(args[2], faults_file)
|
||||
datafile2 <- file.path(queries_dir, paste0(experiments[2], "_", faults_file))
|
||||
data2 <- readr::read_csv(datafile2)
|
||||
data2$fault_address <- strtoi(data2$fault_address)
|
||||
data2$resulttype <- resulttype_labels[data2$resulttype]
|
||||
@@ -77,7 +84,8 @@ plot <- ggplot(
|
||||
theme(legend.position = "none")
|
||||
|
||||
# TODO: Name the file according to the benchmarks
|
||||
dir.create(charts_dir, showWarnings = FALSE, recursive = TRUE)
|
||||
ggsave(
|
||||
paste0(args[2], "/../sankey", suffix, ".svg"),
|
||||
file.path(charts_dir, paste0("sankey", suffix, ".svg")),
|
||||
plot = plot,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user