/
plot.R
executable file
·39 lines (33 loc) · 1.01 KB
/
plot.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env Rscript --vanilla
#
help <- function() {
cat("\nusage: plot.R [-h] <results file>\n\n")
}
args<-commandArgs(TRUE)
if ( length(args) == 0 ) {
cat ("ERROR: Must provide a results file\n")
help()
q(status=1)
}
if ( args[[1]] == "-h" ) {
help()
q(status=0)
}
inputfile <- args[[1]]
# Check if this script can read inputfile
if (file.access(inputfile, 4) != 0 ) {
cat ("ERROR: input file '", inputfile, "' must be readable\n", sep="")
q(status=1)
}
# Ensure outputfile doesn't exist
outputfile <- paste0(inputfile, ".pdf")
if (file.exists(outputfile) != 0 ) {
cat ("ERROR: output file '", outputfile, "' already exists\n", sep="")
q(status=1)
}
title <- paste0("Metadata propagation from the UKf Metadata Publication Service\n(", inputfile, ")")
data <- read.table(inputfile, sep=" ")
timestamp <- strptime( data$V1, tz = "UTC", "%Y-%m-%dT%H:%M:%SZ")
pdf(outputfile)
plot(timestamp, data$V2, type="l", xlab="Time", ylab="Number of IdPs which have downloaded metadata", main=title)
dev.off()