Skip to content

Instantly share code, notes, and snippets.

@schluppeck
Created February 15, 2018 15:16
Show Gist options
  • Select an option

  • Save schluppeck/6033376bf2592a935a0a4792c3eb6802 to your computer and use it in GitHub Desktop.

Select an option

Save schluppeck/6033376bf2592a935a0a4792c3eb6802 to your computer and use it in GitHub Desktop.
summarising grades by questions (tidy_
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