-
Notifications
You must be signed in to change notification settings - Fork 5
/
accessToServices.Rmd
91 lines (52 loc) · 2.57 KB
/
accessToServices.Rmd
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
---
title: "Access to services"
output: word_document
---
```{r, echo=FALSE, results='asis'}
library(plyr)
# Access to services, waiting times, location, raw numbers, percentages and verbatim
# generate table - improve one thing
myImprove = function(){
theCodes = c(passData()$Imp1, passData()$Imp2)
# current sub themes
subcommentList = lapply(SubList, function(x)
theCodes[theCodes %in% unlist(x)])
subfinalList = subcommentList[order(unlist(lapply(subcommentList, length)), decreasing = TRUE)]
subtheComments = sapply(1 : length(names(subfinalList)),
function(x) c(names(subfinalList)[x],
round(length(subfinalList[[x]]) /
length(unlist(subcommentList)) * 100, 1)))
subtheCommentsRaw = sapply(1 : length(names(subfinalList)),
function(x) c(names(subfinalList)[x],
length(subfinalList[[x]])))
# split the super from sub themes
splitThemes = strsplit(as.character(subtheComments[1, ]), " - ")
### put it all together
finalFrame = data.frame("Category" = unlist(lapply(splitThemes, "[", 1)),
"Subcategory" = unlist(lapply(splitThemes, "[", 2)),
"Percentage subcategory" = as.numeric(subtheComments[2, ]),
"Raw numbers" = as.numeric(subtheCommentsRaw[2, ]))
### get rid of missing data
finalFrame = within(finalFrame, {
Percentage.subcategory[is.nan(Percentage.subcategory)] = 0
})
finalFrame = finalFrame[finalFrame$Percentage.subcategory > 0, ]
if(nrow(finalFrame) < 2){
finalFrame = data.frame("Not", "Enough", "Data", "!")
names(finalFrame) = c("Category", "Subcategory", "% subcategory", "Raw count")
} else {
finalFrame = finalFrame[order(finalFrame$Percentage.subcategory, decreasing = TRUE),]
names(finalFrame) = c("Category", "Subcategory", "% subcategory", "Raw count")
}
return(finalFrame)
}
wholeFrame = myImprove()
wholeFrame = wholeFrame[wholeFrame$Category == "Access to Services", ]
kable(wholeFrame, row.names = FALSE)
```
```{r, echo=FALSE, results='asis'}
commentFrame = passData()[, c("Location", "Improve", "Imp1", "Imp2")]
commentFrame = commentFrame[commentFrame$Imp1 %in% SuperList[["Access to Services"]] |
commentFrame$Imp2 %in% SuperList[["Access to Services"]], ]
cat(paste0("<p>", commentFrame$Improve, " (", commentFrame$Location, ")", "</p>"))
```