Grading Exam Scores
Criteria: A (90-100), B (80-89), C (70-79), D (60-69), F (0-59)
R
# Define the grading function for exam scores grade_exam <- function (score) { if (score >= 90) { return ( "A" ) } else if (score >= 80) { return ( "B" ) } else if (score >= 70) { return ( "C" ) } else if (score >= 60) { return ( "D" ) } else { return ( "F" ) } } # Load the dataset student_data <- data.frame ( StudentName = c ( "Alice" , "Bob" , "Charlie" , "David" , "Eve" ), ExamScore = c (85, 72, 93, 60, 78) ) # Apply the grade_exam function to classify students based on exam scores student_data$Grade <- sapply (student_data$ExamScore, grade_exam) # Print the updated dataset with grades print (student_data) |
Output:
StudentName ExamScore Grade
1 Alice 85 B
2 Bob 72 C
3 Charlie 93 A
4 David 60 D
5 Eve 78 C
Grade Classification Based on Multiple Conditions in R
Grade classification based on multiple conditions is a common task in data analysis, often performed using programming languages like R. This process involves assigning grades or labels to data points based on predefined criteria or conditions. In this context, we’ll explore how to classify data into different grades using R, considering various conditions.
Table of Content
- Concepts Related to the Topic:
- Steps Needed:
- Grading Exam Scores
- Grading Customer Satisfaction
- Grade Calculation for Student
- Conclusion
Contact Us