1 | summaryTableRF(survData)
|
survData |
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 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (survData)
{
out <- NULL
out <- rbind(out, c(NA, NA, NA, NA))
x <- as.data.frame(with(survData, table(infstatus, cancer)))
y <- as.data.frame(prop.table(with(survData, table(infstatus,
cancer)), 1))
out <- rbind(out, c(x[x$cancer == T, "Freq"], format(y[y$cancer ==
T, "Freq"], digits = 2)))
x <- as.data.frame(with(survData, table(infstatus, prem)))
y <- as.data.frame(prop.table(with(survData, table(infstatus,
prem)), 1))
out <- rbind(out, c(x[x$prem == T, "Freq"], format(y[y$prem ==
T, "Freq"], digits = 2)))
x <- as.data.frame(with(survData, table(infstatus, cong)))
y <- as.data.frame(prop.table(with(survData, table(infstatus,
cong)), 1))
out <- rbind(out, c(x[x$cong == T, "Freq"], format(y[y$cong ==
T, "Freq"], digits = 2)))
x <- as.data.frame(with(survData, table(infstatus, surgical)))
y <- as.data.frame(prop.table(with(survData, table(infstatus,
surgical)), 1))
out <- rbind(out, c(x[x$surgical == T, "Freq"], format(y[y$surgical ==
T, "Freq"], digits = 2)))
x <- as.data.frame(with(survData, table(infstatus, cath)))
y <- as.data.frame(prop.table(with(survData, table(infstatus,
cath)), 1))
out <- rbind(out, c(x[x$cath == T, "Freq"], format(y[y$cath ==
T, "Freq"], digits = 2)))
x <- as.data.frame(with(survData, table(infstatus, highRisk)))
y <- as.data.frame(prop.table(with(survData, table(infstatus,
highRisk)), 1))
out <- rbind(out, c(x[x$highRisk == T, "Freq"], format(y[y$highRisk ==
T, "Freq"], digits = 2)))
out <- rbind(out, c(NA, NA, NA, NA))
elective <- c("Elective - booked", "Elective - planned",
"Elective - from waiting list")
x <- as.data.frame(with(survData, table(infstatus, hes_admimethdescription %in%
elective)))
y <- as.data.frame(prop.table(with(survData, table(infstatus,
hes_admimethdescription %in% elective)), 1))
out <- rbind(out, c(x[x$Var2 == T, "Freq"], format(y[y$Var2 ==
T, "Freq"], digits = 2)))
emergency <- c("Emergency - other means, including patients who arrive via A&E department of another HC provider",
"Emergency - via A&E services, including casualty department of provider",
"Emergency - via General Practitioner (GP)", "Emergency - via Bed Bureau, including Central Bureau",
"Emergency - via consultant out-patient clinic")
x <- as.data.frame(with(survData, table(infstatus, hes_admimethdescription %in%
emergency)))
y <- as.data.frame(prop.table(with(survData, table(infstatus,
hes_admimethdescription %in% emergency)), 1))
out <- rbind(out, c(x[x$Var2 == T, "Freq"], format(y[y$Var2 ==
T, "Freq"], digits = 2)))
out <- rbind(out, aggregate(as.numeric(tail(out, 2)), by = list(c(1,
1, 2, 2, 3, 3, 4, 4)), sum)$x)
neocare <- c("Level 1 intensive care", "Level 2 intensive care")
x <- as.data.frame(with(survData, table(infstatus, hes_neocaredescription %in%
neocare)))
y <- as.data.frame(prop.table(with(survData, table(infstatus,
hes_neocaredescription %in% neocare)), 1))
out <- rbind(out, c(x[x$Var2 == T, "Freq"], format(y[y$Var2 ==
T, "Freq"], digits = 2)))
out <- rbind(out, c(NA, NA, NA, NA))
x <- as.data.frame(with(survData, table(infstatus, hes_admimethdescription ==
"Transfer of any admitted patient from another hospital provider")))
y <- as.data.frame(prop.table(with(survData, table(infstatus,
hes_admimethdescription == "Transfer of any admitted patient from another hospital provider")),
1))
out <- rbind(out, c(x[x$Var2 == T, "Freq"], format(y[y$Var2 ==
T, "Freq"], digits = 2)))
residence <- c("The usual place of residence, including no fixed abode",
"Temporary place of residence when usually resident elsewhere")
x <- as.data.frame(with(survData, table(infstatus, hes_admisorcdescription %in%
residence)))
y <- as.data.frame(prop.table(with(survData, table(infstatus,
hes_admisorcdescription %in% residence)), 1))
out <- rbind(out, c(x[x$Var2 == T, "Freq"], format(y[y$Var2 ==
T, "Freq"], digits = 2)))
out <- rbind(out, aggregate(as.numeric(tail(out, 2)), by = list(c(1,
1, 2, 2, 3, 3, 4, 4)), sum)$x)
if (ncol(out) == 4) {
colnames(out) <- c("Non-HA-BSI", "HA-BSI", "%", "%")
out <- out[, c(1, 3, 2, 4)]
}
else {
colnames(out) <- c("Non-HA-BSI", "%")
}
rownames(out) <- c("Risk Factors", "Cancer", "Premature birth",
"Congenital disorder", "Surgical", "In-dwelling catheter",
"At least one", "Type of Admission", "Elective", "Emergency",
"TOTAL", "Intensive neonatal care", "Origin of patient",
"Another hospital", "Residence", "TOTAL")
return(out)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.