|
| 1 | +library(ggplot2) |
| 2 | +library(dplyr) |
| 3 | + |
| 4 | +data <- read.csv(header=TRUE, sep = "#", file = file.choose()) |
| 5 | + |
| 6 | +summary = summarise(group_by(data,Variant, Node), |
| 7 | + mean_Length = mean(Length), |
| 8 | + sd_Length = sd(Length), |
| 9 | + mean_IP = mean(InitiateProbe), |
| 10 | + sd_IP = sd(InitiateProbe), |
| 11 | + mean_PT = mean(PassToken), |
| 12 | + sd_PT = sd(PassToken), |
| 13 | + mean_SM = mean(SendMsg), |
| 14 | + sd_SM = sd(SendMsg), |
| 15 | + mean_RM = mean(RecvMsg), |
| 16 | + sd_MR = sd(RecvMsg), |
| 17 | + mean_DA = mean(Deactivate), |
| 18 | + sd_DA = sd(Deactivate), |
| 19 | + mean_T = mean(T), |
| 20 | + sd_T = sd(T), |
| 21 | + mean_T2TD = mean(T2TD), |
| 22 | + sd_T2TD = sd(T2TD) |
| 23 | +) |
| 24 | +Nodes <- unique(summary$Node) |
| 25 | + |
| 26 | +#### |
| 27 | +#### T2TD |
| 28 | +#### |
| 29 | +for (n in Nodes) { |
| 30 | + print(ggplot(filter(summary, Node == n), |
| 31 | + aes(x = reorder(Variant, mean_T2TD), y = mean_T2TD, fill = Variant)) + |
| 32 | + geom_bar(stat = "identity") + |
| 33 | + geom_errorbar(aes(ymin=mean_T2TD-sd_T2TD, ymax=mean_T2TD+sd_T2TD), width=.2, |
| 34 | + position=position_dodge(.9)) + |
| 35 | + scale_x_discrete(guide = guide_axis(n.dodge=3))+ |
| 36 | + theme_minimal() + |
| 37 | + labs( |
| 38 | + x = "Spec variant", |
| 39 | + y = "Average length while terminated /\\ ~terminationDetected holds", |
| 40 | + title = paste( |
| 41 | + "Number of Nodes: ", n, "Traces:", nrow(filter(data, Node == n)) |
| 42 | + ) |
| 43 | + )) |
| 44 | +} |
| 45 | + |
| 46 | +#### |
| 47 | +#### InitiateProbe actions |
| 48 | +#### |
| 49 | +for (n in Nodes) { |
| 50 | + print(ggplot(filter(summary, Node == n), |
| 51 | + aes(x = reorder(Variant, mean_IP), y = mean_IP, fill = Variant)) + |
| 52 | + geom_bar(stat = "identity") + |
| 53 | + geom_errorbar(aes(ymin=mean_IP-sd_IP, ymax=mean_IP+sd_IP), width=.2, |
| 54 | + position=position_dodge(.9)) + |
| 55 | + scale_x_discrete(guide = guide_axis(n.dodge=3))+ |
| 56 | + theme_minimal() + |
| 57 | + labs( |
| 58 | + x = "Spec variant", |
| 59 | + y = "Average number of InitiateProbe actions", |
| 60 | + title = paste( |
| 61 | + "Number of Nodes: ", n, "Traces:", nrow(filter(data, Node == n)) |
| 62 | + ) |
| 63 | + )) |
| 64 | +} |
| 65 | + |
| 66 | +#### |
| 67 | +#### Length & T |
| 68 | +#### |
| 69 | +for (n in Nodes) { |
| 70 | + print(ggplot(filter(summary, Node == n), |
| 71 | + aes(x = reorder(Variant, mean_Length), y = mean_Length, fill = Variant)) + |
| 72 | + geom_bar(stat = "identity") + |
| 73 | + geom_errorbar(aes(ymin=mean_Length-sd_Length, ymax=mean_Length+sd_Length), width=.2, |
| 74 | + position=position_dodge(.9)) + |
| 75 | + scale_x_discrete(guide = guide_axis(n.dodge=3))+ |
| 76 | + theme_minimal() + |
| 77 | + labs( |
| 78 | + x = "Spec variant", |
| 79 | + y = "Average length of behaviors", |
| 80 | + title = paste( |
| 81 | + "Number of Nodes: ", n, "Traces:", nrow(filter(data, Node == n)) |
| 82 | + ) |
| 83 | + )) |
| 84 | +} |
| 85 | + |
| 86 | +######## |
| 87 | +######## Occurrences of actions |
| 88 | +######## |
| 89 | +for (n in Nodes) { |
| 90 | + print(ggplot(filter(summary, Node == n)) + |
| 91 | + geom_point(aes(x=reorder(Variant, mean_PT), y = mean_PT,colour = "PassToken",shape = "PassToken")) + |
| 92 | + geom_point(aes(x=reorder(Variant, mean_IP),y=mean_IP,colour = "InitiateProbe",shape = "InitiateProbe")) + |
| 93 | + # geom_point(aes(x=Variant,y=mean_IP,colour = "InitiateProbe",shape = "InitiateProbe")) + |
| 94 | + geom_point(aes(x=reorder(Variant, mean_SM),y=mean_SM,colour = "SendMsg",shape = "SendMsg")) + |
| 95 | + geom_point(aes(x=reorder(Variant, mean_RM),y=mean_RM,colour = "RecvMsg",shape = "RecvMsg")) + |
| 96 | + geom_point(aes(x=reorder(Variant, mean_DA),y=mean_DA,colour = "Deactivate",shape = "Deactivate")) + |
| 97 | + ## x-axis labels should not overlap. |
| 98 | + scale_x_discrete(guide = guide_axis(n.dodge=3))+ |
| 99 | + #scale_x_discrete(guide = guide_axis(check.overlap = TRUE))+ |
| 100 | + #coord_flip() + |
| 101 | + theme_minimal() + |
| 102 | + #theme(legend.position = "none") + |
| 103 | + labs( |
| 104 | + x = "Spec variant", |
| 105 | + y = "Average number of occurrences in behaviors", |
| 106 | + title = paste( |
| 107 | + "Number of Nodes: ", n, " Traces:", nrow(filter(data, Node == n)) |
| 108 | + ) |
| 109 | + )) |
| 110 | +} |
| 111 | + |
| 112 | +######## |
| 113 | +######## Correlations |
| 114 | +######## |
| 115 | + |
| 116 | +##install.packages("ggcorrplot") |
| 117 | +library("ggcorrplot") |
| 118 | +my_data <- filter(summary, Node == 113)[, c("mean_Length", "mean_SM", "mean_RM", "mean_IP", "mean_PT", "mean_DA", "mean_T")] |
| 119 | +p.mat <- cor_pmat(my_data) |
| 120 | +## Check for correlation in 'data' |
| 121 | +## 'spearman' (3) correlation because data has no normal distribution |
| 122 | +## (see previous plots). |
| 123 | +corr <- round(cor(my_data), 3) |
| 124 | +ggcorrplot(corr, p.mat = cor_pmat(my_data), |
| 125 | + hc.order = TRUE, type = "lower", |
| 126 | + color = c("#FC4E07", "white", "#00AFBB"), |
| 127 | + outline.col = "white", lab = TRUE) |
0 commit comments