Activity 6 - Using APPLY Family Functions
Activity 6 - Using APPLY Family Functions
You are given a dataset with students' grades in three subjects: Math, Science, and English.
1. Using the apply() function, calculate the average score for each student across all three subjects
(Math, Science, and English). Add a new column to the students dataset that contains the
average score.
2. Using the lapply() function, calculate the mean score for each subject (Math, Science, English).
Display the result as a list where each element represents the mean score of a subject.
3. Using the sapply() function, calculate the total score for each subject (Math, Science, and
English). Display the result as a vector where each element represents the total score of a
subject.
4. Using the apply() function, calculate the highest score in each subject (Math, Science, and
English). Use apply() to perform the operation on the columns (i.e., find the maximum value in
each column).
5. Using lapply(), create a new list where each element contains a vector of scores greater than or
equal to 85 for each subject. For example, in the "Math" subject, the result should be a list of
scores in that subject that are greater than or equal to 85.
6. Using sapply(), calculate the standard deviation of scores for each subject. Display the result as a
vector where each element is the standard deviation of a subject.
7. Using the apply() function, create a new column in the students dataset that contains "Pass" if
the average score of the student is greater than or equal to 85, and "Fail" if it is less than 85. Use
apply() to check each student's average score and assign the respective result.
8. Create a new list using lapply() that contains the count of scores greater than or equal to 90 for
each subject. Then, use the apply() function to find the total number of students with scores
greater than or equal to 90 across all subjects.