-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample.Rmd
More file actions
273 lines (195 loc) · 8.4 KB
/
example.Rmd
File metadata and controls
273 lines (195 loc) · 8.4 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
---
title: "Example"
output:
rmarkdown::html_vignette:
df_print: kable
vignette: >
%\VignetteIndexEntry{Example}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
out.width = "100%",
fig.width = 10,
fig.height = 7
)
# devtools::install_github("psyteachr/glossary")
library(glossary)
```
```{r setup}
library(markr)
library(dplyr) # for data manipulation
library(ggplot2) # to customise plots
```
## Quickstart Demo
Markr has an example marking project that you can use to learn about the package. Run the following code to create a `r glossary("directory")` called `markr_example` and open the file `demo.Rmd`.
``` r
markr::markr_example()
```
### Open a marking file
You can open the file `marks.csv` in Excel, but the code below opens it in R and you can click on the `r glossary("object")` `marks` in the Environment `r glossary("panes", "pane")`. This data table has a column for the student ID, three columns for category marks (KR, CE and AC), a column for the numeric mark, and a column with individual text feedback.
```{r, eval = FALSE}
marks <- read_marks("marks_fb.csv")
```
```{r, echo = FALSE}
marks <- demo_marks
marks
```
### Data Processing
Markr has a convenience function for translating between number and letter grades for different purposes, such as numbers for averaging marks and letters for reporting final grades. It defaults to the `glasgow22()` scale, but you can add your own scale.
```{r}
scale <- data.frame(
numbers = 4:0,
letters = c("A", "B", "C", "D", "E")
)
marks$grade <- convert_grades(marks$mark, to = "letters", scale)
select(marks, mark, grade)
```
### Edit the Template
You will need to create a template `r glossary("R markdown")` file for individual feedback. You can get a demo template using **`New File > R Markdown... > From Template`**.
Each file will have two data objects available to it:
* `marks` (the whole marking spreadsheet)
* `student` (the individual student's data)
In the most typical case, where each student has one row in the spreadsheet, you can reference the student's data in code `r glossary("chunk", "chunks")` or inline R like this:
```{verbatim}
---
title: "Feedback"
date: `r format(Sys.time(), '%d %B, %Y')`"
output: html_document
---
**Student**: `r student$name`
**Marker**: `r student$marker`
**Grade**: `r student$grade`
```
### Category Tables
You can display a table of marks for specific criteria by specifying the column names (`cols`) for each criterion and the order that the categories should go in (`cats`).
```{r}
student <- filter(marks, ID == "S2")
category_table(student, cols = c("KR", "CE", "AC"), cats = 1:4)
```
You can translate abbreviations used in the marking sheet using `r glossary("list", "lists")` and even change the `symbol` to an emoji.
```{r}
# set order and translation of criteria columns
# exact column header names = names to display in the table
cols <- list(
"KR" = "Knowledge and Research",
"CE" = "Critical Evaluation",
"AC" = "Academic Communication"
)
# set order and translation of category labels
# category values = labels to display in the table
cats <- list(
"1" = "Needs Work",
"2" = "Acceptable",
"3" = "Good",
"4" = "Outstanding"
)
# create table for this student
category_table(student, cols, cats, symbol = "✅")
```
### Create Feedback
Once you have your marks and feedback in a table and a template file ready, you can create a feedback document for each student with the `make_feedback()` `r glossary("function")`.
Make sure to set the `filename` to something unique for each student. You can use any columns in the marks table as part of the filename.
```{r, eval = FALSE}
tempfile <- system.file("basic", "template.Rmd", package = "markr")
x <- make_feedback(
marks = marks, # or path to tabular data
template = tempfile,
filename = "fb/[ID]_[question]"
)
```
## Marking Data
If you have longer blocks of feedback text, the `r glossary("YAML")` style of marking sheet might work better than spreadsheets. It can be a little tricky to get YAML to parse right, but after you've mastered it, it's an efficient way to store your marking feedback text.
You can include all of the columns or just the student ID and feedback, then join this to the spreadsheet table.
### All data in YAML
```
- ID: S10
name: Helena
marker: Lisa
KR: 4 # use a hash to add comments
CE: 4
AC: 3
mark: A5
feedback: |
Here is a paragraph of feedback.
## A list of feedback
* item 1
* item 2
```
```{r, eval = FALSE}
# all data in one YAML file
marks <- read_marks(yaml = "marks_fb.yml")
```
### Convert table to YAML
If you have `r glossary("tabular data")` and want to convert it to YAML, use the function `tbl2yaml()`. You can add extra columns (or overwrite existing columns). Add a `filename` to save to file.
```{r, eval = FALSE}
tbl2yaml(marks, filename = "demo.yml", marker = "Lisa")
```
If you just have a list of IDs and want to create a YAML file for feedback, you can set it up without a pre-existing table. Use `"...\n"` to insert a place-holder for multi-line info, such as feedback paragraphs
```{r, eval = FALSE}
tbl2yaml(ID = marks$ID, feedback = "...\n")
```
<pre><code>
```{r, echo = FALSE, results='asis'}
tbl2yaml(ID = marks$ID, feedback = "...\n", open = FALSE) %>% cat()
```
</code></pre>
### Data in both formats
You can just use YAML for paragraphs of text and put all other data in a table. Set up the YAML file with corresponding ID columns to join rows.
```{r, eval = FALSE}
marks <- read_marks(tbl = "marks.csv",
yaml = "fb.yml",
join_by = "ID")
```
## Summary Plots
You can display a summary plot of the marks in the student feedback or for your own purposes.
```{r mark-dist-plot-1, fig.alt="Bar plot of the mark distribution. The N's for the scores 0-5 are 0=0, 1=1, 2=1, 3=1, 4=2, 5=0"}
mark_dist(marks, "mark", scale = 0:5)
```
### Faceted plots
Here we've made a new `marks` table with 100 students. Each student answered one of three questions, indicated by the `questions` column.
```{r, echo = FALSE}
marks <- data.frame(
ID = 1:100,
question = sample(1:3, 100, T),
KR = sample(1:4, 100, T),
CE = sample(1:4, 100, T),
AC = sample(1:4, 100, T),
# simulate a bimodal distribution
mark = c(rbinom(80, 22, .7),
rbinom(20, 22, .3))
) %>%
mutate(letter = convert_grades(mark),
grade_band = gsub("[0-9]", "", letter))
head(marks)
```
You can plot the letter grade by question using the following code. To get the letters to display in the right order, we set the `scale` `r glossary("argument")` to the categories in the order we want to show them. The Glasgow 22-point scale has 4 categories we don't want to show on this plot, so you can quickly get the values we do want using the code `glasgow22()$letters[5:26]`, or you can manually create a `r glossary("vector")` with the scale order like `c("G2", "G1", "F3", ..., "A1")`.
```{r mark-dist-by-q-plot, fig.alt="Plot of the mark distribution separated by question"}
mark_dist(marks,
mark_col = "letter",
fill_col = "grade_band",
facet_by = "question",
scale = glasgow22()$letters[5:26])
```
### Category plots
This marking table has three columns that show individual marking criteria: `KR`, `CE` and `AC`, so we could also make a plot of the individual criteria by question. This function uses the `cols` and `cats` lists we made above to translate the abbreviations in the marking table to the full terms in the plot.
```{r cat-dist-plot, fig.alt="Plot of the distribution of the individual criteria for each question."}
cat_dist(marks, cols, cats, facet_by = "question")
```
### Category histograms
The default category plots are stacked bar plots.
Set `xaxis = "cat"` to display the categories across the x-axis instead. The output is a ggplot object, so you can add further ggplot functions to customise your plots.
```{r cat-dist-x-plot, message = FALSE, warning = FALSE, fig.alt="Plot of the distribution of the individual criteria for each question with a red, ornage and yellow colour scheme."}
cat_dist(marks, cols, cats, xaxis = "cat",
facet_by = "question") +
scale_fill_manual(values = c("firebrick", "sienna", "goldenrod", "darkgreen")) +
theme(strip.text.x = element_text(size = 20)) +
scale_y_continuous(breaks = seq(0, 12, 4))
```
## Glossary
```{r, echo = FALSE}
glossary::glossary_table()
```