Create and save the file p3.R on your computer. The file p3.R, which should contain all the required functions.

Problem 1: Conversion to Grade Points

Write a function named num2GP that takes in a numerical score in a range of 0-100, and returns the grade-point value that corresponds to that score. Use the table below (adapted from Princeton’s table here), with 4.0 being the highest possible grade-point value. The conversion from scores to grade points should be done using

##    grade  range grade.point
## 1     A  93-100         4.0
## 2     A-  90-92         3.7
## 3     B+  87-89         3.3
## 4     B   83-86         3.0
## 5     B-  80-82         2.7
## 6     C+  77-79         2.3
## 7     C   73-76         2.0
## 8     C-  70-72         1.7
## 9     D   60-69         1.0
## 10    F    0-59         0.0

For example, the value of num2GP(90) should be 3.7.

Problem 2: Compute GPA

The following code can be used to define a data frame containing a student’s scores.

student.scores <- data.frame("course" = c("Math 12", "English 12", "Geography 10"),
                             "score"  = c(98, 90, 85))

Write a function named student.GPA that takes in a data frame in a format like the one of the data frame above, and returns the student’s GPA. Use the function you wrote in Problem 1.

Note: the Grade Point Average (GPA) is the average of the grade point values of individual courses. For example, if Bob got a score of 90 in English and a score of 99 in French, that means Bob’s English grade is A- and Bob’s French grade is A, so that Bob’s GPA is \((3.7+4.0)/2 = 3.85\). It is incorrect to try to compute the GPA by first averaging the scores to get \(95.5\), and then converting the \(95.5\) to a \(4.0\).

Problem 3: Compute GPA for every student

Now, consider tables in the following format

scores <- data.frame( "name" = c("Bob", "Bob", "Bob", "Alice", "Alice", "Alice"),
                      "course" = c("Math 12", "English 12", "Geography 10", "Math 12", "English 12", "Geography 10"),
                      "score" = c(98, 90, 85, 100, 90, 95))

Write a function named compute.student.GPAs which takes in a data frame in the format like the data frame above, and returns a table that contains the GPAs of each student in the table. The name of the column you create should be "GPA". (Note: you might not want to use the function from Problem 2 directly)