Created
February 15, 2018 15:16
-
-
Save schluppeck/6033376bf2592a935a0a4792c3eb6802 to your computer and use it in GitHub Desktop.
summarising grades by questions (tidy_
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(tidyverse) | |
| # simulate data | |
| n_students <- 50; | |
| grades <- c(100, | |
| 85, | |
| 78, | |
| 72, | |
| 68, | |
| 65, | |
| 62, | |
| 58, | |
| 55, | |
| 52 | |
| ) | |
| questions <- c(1,2,3,4) | |
| sample_data = data_frame(g = sample(grades, n_students, replace=TRUE), q = sample(questions, n_students, replace=TRUE)) | |
| # summarise data | |
| grade_summary <- sample_data %>% | |
| group_by(q) %>% | |
| summarise(mean_grade = mean(g), | |
| median_grade = median(g)) %>% | |
| arrange(q) | |
| # look at data | |
| head(grade_summary) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment