I started learning R last week and have a dataset of test scores for students K-12. There is a column for grade (k-12), Discipline (Math, Reading, Science), and a test score. I need to create a column that links the test score with a proficiency level. So if a student scores between 0-147, they are assigned a "limited" proficiency level, 148-158 "standard" and so on. The issue is, the cut points for the different proficiency levels change by grade and by subject. I am trying to avoid doing a huge ifelse loop in R.
I tried assigning vectors for the cutpoints for each subject and grade combination like this so I could use the findInterval functions
K_math <- c(0, 147, 151, 158, 167, 350)
levels <- c("Limited", "Standard", "Proficient", "Accelerated", "Advanced")
Then
mutate(test_scores$_df$proficiency_level <- case_when(Grade == "K" & Discipline == "Mathematics" & findInterval(test_scores_df$RawTestScore, K_math, left.open = TRUE) ~ levels))
Please help
Aucun commentaire:
Enregistrer un commentaire