forked from kbriney/libStats
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLibStats_report_person.Rmd
More file actions
281 lines (203 loc) · 8.27 KB
/
LibStats_report_person.Rmd
File metadata and controls
281 lines (203 loc) · 8.27 KB
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
---
title: "Personal Statistics Report"
params:
fpath: "C:/Users/briney/Documents/LibStats/reports/data"
periodStart: "2018-01-01 00:00:00"
periodEnd: "2018-05-30 23:59:59"
person: "nbungert"
output:
pdf_document:
fig_width: 7
fig_height: 3
---
<!--
## Name: LibStats_report_person.Rmd
## Created: June 2018 by Kristin Briney
## Purpose: This Rmarkdown template will create a personal report using cleaned StatBot data.
## Staff ePanther ID and date ranges must be specified.
-->
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE, warning=FALSE, message=FALSE)
library(tidyverse)
library(stringr)
library(lubridate)
library(knitr)
## Set parameters -- CHANGE AS NECESSARY
pStart <- ymd_hms(params$periodStart)
pEnd <- ymd_hms(params$periodEnd)
pers <- params$person
## Load consultation data
finput <- paste(params$fpath, "Cons.csv", sep="/")
Cons_all <- read_csv(finput)
Cons <- filter(Cons_all, Cons_all$StaffName==pers & Cons_all$ConsDate>=pStart &
Cons_all$ConsDate<=pEnd)
## Load presentation data
finput <- paste(params$fpath, "Pres.csv", sep="/")
Pres_all <- read_csv(finput)
Pres <- filter(Pres_all, Pres_all$StaffName==pers & Pres_all$PresDateTime>=pStart &
Pres_all$PresDateTime<=pEnd)
## Load transaction data
finput <- paste(params$fpath, "Trans.csv", sep="/")
Trans_all <- read_csv(finput)
Trans <- filter(Trans_all, Trans_all$StaffName==pers &
Trans_all$TransDateTime>=pStart &
Trans_all$TransDateTime<=pEnd)
```
### Person: `r pers`
### Time period: `r pStart` to `r pEnd`
## Transactions
__Total `r pers` transactions = `r count(Trans)`__
### Transaction Patron Status
```{r TuserType}
TuserTypes <- group_by(Trans, UserStatus) %>% mutate(total=n()) %>%
select(UserStatus, total) %>% unique() %>% arrange(desc(total))
ggplot(data=TuserTypes, mapping=aes(x=UserStatus, y=total, label=total)) +
theme_light() +
theme(legend.position="none") +
geom_col(fill="#999999") +
geom_text() +
labs(x="User Status", y="Number of Transactions")
```
### Transaction Courses
```{r Tinstruction}
Tinstruction <- group_by(Trans, Department, Course) %>% mutate(total=n()) %>%
select(Department, Course, total) %>% unique() %>% filter(Department != "NA") %>%
arrange(Department, Course)
kable(Tinstruction, format="latex")
```
### Transaction Type
_Transactions can be coded as multiple types, meaning the sum of the totals
in each category may exceed the total number of transactions_
```{r Ttype}
Ttype_type <- bind_rows(tibble(Ttype="Directional"), tibble(Ttype="Informational"),
tibble(Ttype="Referral"), tibble(Ttype="Reference"))
Ttype_total <- bind_rows(count(filter(Trans,Directional==TRUE)),
count(filter(Trans, Informational==TRUE)),
count(filter(Trans, Referral==TRUE)),
count(filter(Trans, Reference==TRUE)))
Ttype <- bind_cols(Ttype_type, Ttype_total)
ggplot(data=Ttype, mapping=aes(x=Ttype, y=n, label=n)) +
theme_light() +
theme(legend.position="none") +
geom_col(fill="#999999") +
geom_text() +
labs(x="Type", y="Number of Transactions")
```
### Transaction Format
```{r Tform}
Tform <- group_by(Trans, Format) %>% mutate(total=n()) %>%
select(Format, total) %>% unique() %>%
filter(Format=="in person/face to face" | Format=="on the phone" | Format=="over e-mail") %>%
arrange(desc(total))
ggplot(data=Tform, mapping=aes(x=Format, y=total, label=total)) +
theme_light() +
theme(legend.position="none") +
geom_col(fill="#999999") +
geom_text() +
labs(x="Format", y="Number of Transactions")
```
### Transaction Notes
```{r Tnotes}
Tnotes <- select(Trans, TransDateTime, Notes) %>% filter(!is.na(Notes)) %>% arrange(TransDateTime)
kable(Tnotes, format="latex")
```
## Consultations
__Total `r pers` consultations = `r count(Cons)`__
__Total number of patrons in consultations = `r tally(Cons, Count)` (average = `r as.integer(tally(Cons, Count)/count(Cons))`)__
### Consultation Patron Status
```{r CuserType}
CuserTypes <- group_by(Cons, UserStatus) %>% mutate(total=n()) %>%
select(UserStatus, total) %>% unique() %>% arrange(desc(total))
ggplot(data=CuserTypes, mapping=aes(x=UserStatus, y=total, label=total)) +
theme_light() +
theme(legend.position="none") +
geom_col(fill="#999999") +
geom_text() +
labs(x="User Status", y="Number of Consultations")
```
### Consultation Courses
```{r Cinstruction}
Cinstruction <- filter(Cons, !is.na(Course)) %>%
group_by(Department, Course) %>% mutate(total=n()) %>%
select(Department, Course, total) %>% unique() %>% arrange(Department, Course)
kable(Cinstruction, format="latex")
```
### Patron Departments for non-Course Consultations
```{r CuserDept}
CuserDept <- filter(Cons, is.na(Course)) %>% group_by(UserDept) %>% mutate(total=n()) %>%
select(UserDept, total) %>% unique() %>% filter(UserDept != "NA") %>% arrange(desc(total), UserDept)
kable(CuserDept, format="latex")
```
### Consultation Format
```{r Cform}
Cform <- group_by(Cons, Format) %>% mutate(total=n()) %>%
select(Format, total) %>% unique() %>% arrange(desc(total))
ggplot(data=Cform, mapping=aes(x=Format, y=total, label=total)) +
theme_light() +
theme(legend.position="none") +
geom_col(fill="#999999") +
geom_text() +
labs(x="Format", y="Number of Consultations")
```
### Consultation Notes
```{r Cnotes}
Cnotes <- select(Cons, ConsDate, Notes) %>% filter(!is.na(Notes)) %>% arrange(ConsDate)
kable(Cnotes, format="latex")
```
## Presentations
__Total `r pers` presentations = `r count(Pres)`__
__Total number of patrons in presentations = `r as.integer(tally(Pres, Count))` (average = `r as.integer(tally(Pres, Count)/count(Pres))`)__
__Total presentation time = `r as.integer(tally(Pres, Length))` minutes (average = `r as.integer(tally(Pres, Length)/count(Pres))` minutes)__
### Presentation Patron Status
```{r PuserType}
PuserType_type <- bind_rows(tibble(UserType="Undergraduates"), tibble(UserType="Graduates"),
tibble(UserType="FacultyStaff"), tibble(UserType="Children"),
tibble(UserType="HighSchool"), tibble(UserType="NonUWM"))
PuserType_total <- bind_rows(count(filter(Pres,Undergraduates==TRUE)),
count(filter(Pres, Graduates==TRUE)),
count(filter(Pres, FacultyStaff==TRUE)),
count(filter(Pres, Children==TRUE)),
count(filter(Pres, HighSchool)),
count(filter(Pres, NonUWM==TRUE)))
PuserType <- bind_cols(PuserType_type, PuserType_total)
ggplot(PuserType, mapping=aes(x=UserType, y=n, label=n)) +
theme_light() +
theme(legend.position="none") +
geom_col(fill="#999999") +
geom_text() +
labs(x="User Type", y="Number of Presentations")
```
### Presentation Courses
```{r Pinstruction}
Pinstruction <- group_by(Pres, Department, Course) %>% mutate(total=n()) %>%
select(Department, Course, total) %>% unique() %>% filter(Department != "NA") %>%
arrange(Department, Course)
kable(Pinstruction, format="latex")
```
### Presentation Type
```{r Ptype}
Ptype <- group_by(Pres, PresType) %>% mutate(total=n()) %>%
select(PresType, total) %>% unique() %>% arrange(desc(total))
ggplot(data=Ptype, mapping=aes(x=PresType, y=total, label=total)) +
theme_light() +
theme(legend.position="none") +
geom_col(fill="#999999") +
geom_text() +
labs(x="Presentation Type", y="Number of Presentations")
```
### Presentation Format
```{r Pform}
Pform <- group_by(Pres, Format) %>% mutate(total=n()) %>%
select(Format, total) %>% unique() %>% arrange(desc(total))
ggplot(data=Pform, mapping=aes(x=Format, y=total, label=total)) +
theme_light() +
theme(legend.position="none") +
geom_col(fill="#999999") +
geom_text() +
labs(x="Format", y="Number of Presentations")
```
### Presentation Notes
```{r Pnotes}
Pnotes <- select(Pres, PresDateTime, Notes) %>% filter(!is.na(Notes)) %>% arrange(PresDateTime)
kable(Pnotes, format="latex")
```