-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathextsim-summaryfunctions.R
45 lines (41 loc) · 2.39 KB
/
extsim-summaryfunctions.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
# --------------------------------------------------------------------------- #
# CBM systems paper - extended simulation study for revision -
# summary and labeller functions for objects generated by the simulations
# --------------------------------------------------------------------------- #
simsummary <- function(simlist){
data.frame(id = 1:length(simlist),
nfails = sapply(simlist, function(res) sum(res$tfunc != res$tend)),
meantend = sapply(simlist, function(res) mean(res$tend)),
meancostrate = sapply(simlist, function(res) weighted.mean(res$costrate, res$tend)))
}
simsummary2 <- function(simlist){
nrep <- length(simlist)
ncyc <- length(simlist[[1]]$tend)
data.frame(repid = rep(1:nrep, each = ncyc),
cycid = rep(1:ncyc, nrep),
failed = as.vector(sapply(simlist, function(res) res$tfunc != res$tend)),
tend = as.vector(sapply(simlist, function(res) res$tend)),
costrate = as.vector(sapply(simlist, function(res) res$costrate)))
}
simlabeller <- as_labeller(c(nfails = "Number of system failures",
meantend = "Average cycle length",
meancostrate = "Average unit cost rate"))
simlabeller2 <- as_labeller(c(nfails = "Number of system failures",
meantend = "Average cycle length",
meancostrate = "Average unit cost rate",
"Continuous update" = "Continuous update",
"Cycle end update" = "Cycle end update",
"No update" = "No update",
"Age-based with update" = "Age-based with update",
"Age-based without update" = "Age-based without update",
"Corrective" = "Corrective"))
simlabeller3 <- as_labeller(c(nfails = expression(n[failures]),
meantend = expression(bar(t)[sys]),
meancostrate = expression(bar(g)),
"Continuous update" = "CBMcpu",
"Cycle end update" = "CBMepu",
"No update" = "CBMnpu",
"Age-based with update" = "ABMepu",
"Age-based without update" = "ABMnpu",
"Corrective" = "CM"))
#