-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathphystats.R
executable file
·72 lines (59 loc) · 2.34 KB
/
phystats.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env Rscript
library(ggplot2)
library(reshape2)
args <- commandArgs(TRUE)
csvfile <- args[[1]]
pfx <- args[[2]]
base_rates <- function(df) {
ncols <- length(df)
nrows <- length(df[,1])
delta_t <- (df[nrows,1] - df[1,1])
dnames <- colnames(df)
ret <- new.env()
for (i in 2:ncols) {
assign(dnames[i],
(df[nrows,i] - df[1,i]) / delta_t,
envir=ret)
}
ret
}
df <- as.data.frame(read.csv(csvfile, header=T))
bases <- base_rates(df)
df$time_seconds <- df$time_seconds - df$time_seconds[1]
df$dot11FCSErrorCount <- df$dot11FCSErrorCount - df$dot11FCSErrorCount[1]
df$received_fragment_count <- df$received_fragment_count - df$received_fragment_count[1]
df$dot11FCSErrorCount_vs_line <- df$dot11FCSErrorCount -
(df$time_seconds * bases$dot11FCSErrorCount)
df$received_fragment_count_vs_line <- df$received_fragment_count -
(df$time_seconds * bases$received_fragment_count)
df2 <- melt(df, id=c("time_seconds"),
variable.name="Counter", value.name="Value",
measure.vars=c("dot11FCSErrorCount", "received_fragment_count"))
p1 <- ggplot(df2, aes(x=time_seconds, y=Value, colour=Counter)) +
geom_point() +
stat_smooth() +
theme(legend.position=c(1, 0),
legend.justification=c(1,0)) +
xlab("Time (s)") + ggtitle(csvfile)
# plot fraction of frames that are bad
dffrac <- data.frame(df$time_seconds)
colnames(dffrac)[1] <- "time_seconds"
dffrac$fraction_bad <- 100.0 * df$dot11FCSErrorCount / df$received_fragment_count
p2 <- ggplot(dffrac, aes(x=time_seconds, y=fraction_bad)) +
geom_point(colour="red") +
xlab("Time (s)") +
ylab("dot11FCSErrorCount / received_fragment_count (%)") + ggtitle(csvfile)
df3 <- melt(df, id=c("time_seconds"),
variable.name="Counter", value.name="Value",
measure.vars=c("dot11FCSErrorCount_vs_line",
"received_fragment_count_vs_line"))
p3 <- ggplot(df3, aes(x=time_seconds, y=Value, colour=Counter)) +
geom_point() +
stat_smooth() +
geom_hline(y=0, linetype=2) +
theme(legend.position=c(1, 0),
legend.justification=c(1,0)) +
xlab("Time (s)") + ggtitle(csvfile)
ggsave(p1, file=paste(pfx, "_raw.pdf", sep=""), width=8, height=5)
ggsave(p2, file=paste(pfx, "_fraction_bad.pdf", sep=""), width=8, height=5)
ggsave(p3, file=paste(pfx, "_vs_linear.pdf", sep=""), width=8, height=5)