Reference no: EM132372267
Assignment- R basics
Manipulating dataframes
This homework walks you through some typical operations on data frames that we use often in this class.
1. Create a random 70 × 5 matrix with 70 rows, 5 columns, with integer entries between 0 and 100. Call this matrix M.
Hint: use the function runif. We shall interpret M as the scoresheet of a math class: the rows correspond to student, and the columns of M are the scores of 5 different assignments in this class.
2. Turn M into a dataframe. Hint: use as.data.frame
3. Give the columns of M the following names: "homework1", "homework2", "homework3", "midterm", "final".
Hint: use names The total score in this fictious class is: 20% midterm + 60% final + 20% from homework.
3. Compute the score, and store it as a new column score in M.
4. Compute the letter grades for your students based on these rules: the top 5% of the class receive A, the next 15% receive B, the next 30% receive C, the next 20% receive D, and the rest F.
Hint: you can find the cut-off scores for the various letter grades with the command quantile. Then you can use cut
5. Compute the mean final exam score for all the students whose final letter grade is A or B. Basic plots with R
The ggplot command in the ggplot2 library makes beautiful plots. However, if you just want a ‘quick and dirty' plot and not worry about the aesthetics, R has some useful base commands.
6. Do a histogram of score using the command hist, and do a boxplot of score using the command boxplot.
Attachment:- Assignment Data.rar