/
summarize_results.R
115 lines (96 loc) · 3.79 KB
/
summarize_results.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
library(dplyr)
library("readxl")
#===================================================================
# Case-based results
#===================================================================
# Set directory to load data
dir = dirname(rstudioapi::getSourceEditorContext()$path)
setwd(dir)
# Load data
data <- read_excel("model.xlsx", sheet = "Summary")
# transpose data
data <- t(data)
# store in data.frame
df = data.frame(data)
# set heading as first row
names(df) <- data[c(1),]
# remove rows
df <- df[-c(1, 2, 3), ]
# remove entries without capture
df<-df[!(df$captureType1=="None"),]
# set entires as numeric data
df$GWP_total <- as.numeric(as.character(df$GWP_total))
df$EROI <- as.numeric(as.character(df$EROI))
df$WU_total <- as.numeric(as.character(df$WU_total))
df$EU_total <- as.numeric(as.character(df$EU_total))
df$effReduction <- as.numeric(as.character(df$effReduction))
df$ccRate <- as.numeric(as.character(df$ccRate))
# Summarise data
df_smry <- df %>% # the names of the new data frame and the data frame to be summarised
group_by(.dots=c("powerPlantType","captureType1", "PrePostOxy")) %>% # the grouping variable
summarise(count=n(), # counts number of entries
GWP_min = min(GWP_total), # calculates the minimum
GWP_mean = mean(GWP_total), # calculates the mean
GWP_max = max(GWP_total),# calculates the maximum
EROI_min = min(EROI),
EROI_mean = mean(EROI),
EROI_max = max(EROI),
WU_min = min(WU_total),
WU_mean = mean(WU_total),
WU_max = max(WU_total),
EU_min = min(EU_total),
EU_mean = mean(EU_total),
EU_max = max(EU_total),
effReduction_min = min(effReduction),
effReduction_mean = mean(effReduction),
effReduction_max = max(effReduction),
ccRate_min = min(ccRate),
ccRate_mean = mean(ccRate),
ccRate_max = max(ccRate),
)
# Convert from g to kg
df_smry$GWP_min <- df_smry$GWP_min / 1000.0
df_smry$GWP_mean <- df_smry$GWP_mean / 1000.0
df_smry$GWP_max <- df_smry$GWP_max / 1000.0
# Convert from cm^3 to l
df_smry$WU_min <- df_smry$WU_min / 1000.0
df_smry$WU_mean <- df_smry$WU_mean / 1000.0
df_smry$WU_max <- df_smry$WU_max / 1000.0
# save data
write.csv(df_smry, "summary.csv")
#==================
# Secondary summary - plant type + capture type, not distinquishing between pre/post
#==================
# Summarise data
df_smry2 <- df %>% # the names of the new data frame and the data frame to be summarised
group_by(.dots=c("powerPlantType","captureType1")) %>% # the grouping variable
summarise(count=n(), # counts number of entries
GWP_min = min(GWP_total), # calculates the minimum
GWP_mean = mean(GWP_total), # calculates the mean
GWP_max = max(GWP_total),# calculates the maximum
EROI_min = min(EROI),
EROI_mean = mean(EROI),
EROI_max = max(EROI),
WU_min = min(WU_total),
WU_mean = mean(WU_total),
WU_max = max(WU_total),
EU_min = min(EU_total),
EU_mean = mean(EU_total),
EU_max = max(EU_total),
effReduction_min = min(effReduction),
effReduction_mean = mean(effReduction),
effReduction_max = max(effReduction),
ccRate_min = min(ccRate),
ccRate_mean = mean(ccRate),
ccRate_max = max(ccRate),
)
# Convert from g to kg
df_smry2$GWP_min <- df_smry2$GWP_min / 1000.0
df_smry2$GWP_mean <- df_smry2$GWP_mean / 1000.0
df_smry2$GWP_max <- df_smry2$GWP_max / 1000.0
# Convert from cm^3 to l
df_smry2$WU_min <- df_smry2$WU_min / 1000.0
df_smry2$WU_mean <- df_smry2$WU_mean / 1000.0
df_smry2$WU_max <- df_smry2$WU_max / 1000.0
# save data
write.csv(df_smry2, "summary2.csv")