This file contains a set of tasks that you need to complete in R for the lab assignment. The tasks may require you to add a code chuck, type code into a chunk, and/or execute code. Some tasks may also ask you to answer specific questions. Don’t forget that you need to acknowledge if you used any resources beyond class materials or got help to complete the assignment.
Instructions associated with this assignment can be found in the file “InstructionsPlayingwithData.html”.
The data set you will use is different than the one used in the instructions. Pay attention to the differences in the Excel files name, any variable names, or object names. You will need to adjust your code accordingly.
Once you have completed the assignment, you will need to knit this R Markdown file to produce an html file. You will then need to upload the .html file and this .Rmd file to AsULearn. Additionally, for this assignment you will upload the Excel file you created.
The first thing you need to do in this file is to add your name and date in the lines underneath this document’s title (see the code in lines 10 and 11).
Insert a chunk of code in this section to identify and set your
working directory and load packages. We will use the same three packages
we did in the last lab: openxlsx, dplyr and
tidyverse.
library(readxl) Assignment5_GradeBook <-
read_excel(“Assignment5_GradeBook.xlsx”) View(Assignment5_GradeBook)
library(“openxlsx”) library(“tidyverse”) library(“dplyr”)
Insert a chunk of code in this section to load your data. The Excel file for this assignment has two sheets: grades and attendance. Sheet 1 contains the grades data and sheet 2 contains the attendance data. You will want to load each sheet into R as separate data objects. The name of the Excel file is different than what is in the instructions. Accordingly, you will need to adjust the code to read in the Excel file that was downloaded as part of the zip file. GradeBook <- read_excel(“Assignment5_GradeBook.xlsx” , sheet = 1) head(GradeBook, 16) Attendance <- read_excel(“Assignment5_GradeBook.xlsx” , sheet = 2) head(Attendance, 16) # 4. Take a look at your data Insert a chunk of code in this section and display the first 15 observations of each data set. head(Assignment5_GradeBook,15)
You will need to insert chunks of code and rename variables in your data sets in this section. I recommend trying to do only one thing per chunk of code.
In the attendance data set, you will need to rename the variables
that are currently numbers into text. In the instructions, I called each
variable Class and then the number of that class, for
example Class1. Instead of using the same variable name as
I did, you should call each variable a meeting. Attendance
%>% rename(Meeting1 = “1”, Meeting2 = “2”, Meeting3 = “3”, Meeting4 =
“4”, Meeting5 = “5”) -> Attendance
In the grade book data set, rename the variables so that they do not
have a . in their names. GradeBook %>% rename(Name = ““,
Midterm1 =”Midterm.1”, Midterm2 = “Midterm.2”, Assignment1 =
“Assignment.1”, Assignment2 = “Assignment.2”, Assignment3 =
“Assignment.3”, Final = “Final”) -> GradeBook
After renaming the variables, look at the first 15 observations for each data set. head(Attendance,15) # 6. Creating New Attendance Variables In this section, insert chunks and create the following variables in your attendance data set.
Total number of classes attended.
Total number of classes absent. There are a total of 5 classes that students could potentially attend.
Total number of unexcused absences. Students are allowed up to 2 excused absences.
Penalty on grade for unexcused absences. For each unexcused absence, a student’s grade will be penalized 0.5 points. Based on the number of unexcused absences, calculate the total penalty that should be applied to their grade.
After you have completed these calculations, take a look at the first 15 observations in your data set.
In this section, insert chunks and create the following variables in your grade book data set.
Each assignment in class is worth 10 points. Create a new variable for each assignment where you covert the raw score into a percent. GradeBook %>% mutate(PerMT1 = (Assignment 1/10)*100) -> GradeBook
Each midterm in the class is worth 20 points. Create a new variable for each midterm where you convert the raw score into a percent.
The final exam is worth 30 points. Create a new variable for the final where you convert the raw score into a percent.
There are multiple ways one can calculate the overall grade for the class. You are going to calculate the final grade in two different ways.
You should provide equal weight to each item in the class regardless of the number of points it was originally worth. To do this, you should add together the percentage grades that you calculated and divide by 600 (you have 6 assignments, each one is worth up to 100 points once the grades were converted to percents).
You should weight items based on the number of points each was originally worth. The most straightforward way to do this is to add together the raw scores for each item and then divide by the total number of points possible. You already have the information you need to calculate the total number of points possible because you know how many points each type of assignment is worth and you know how many of each type of assignment is in the grade book.
After you have completed these calucations, take a look at the first 15 observations in your data set.
In this section, insert chunks and calculate mean, minimum, and
maximum for 3 different variables (midterm 2, assignment 3, and the
final exam) in the grade book data set. Use the variables that report
the scores as a percent that you created.
print(mean_PerMT2) # 9. Create Objects Containing Multiple Values In
this section, insert chunks and produce the following objects that will
contain values for each variable in the data set.
Using the attendance data, create two objects. One object should contain the total number of students attending a class session. One object should contain the mean number of students attending a class session.
Using the grade book data, create three objects with the mean, min, and max grades for each of the variable in the data set.
In this section, insert chunks of code that will combine objects together.
Combine the two objects you created using the attendance data set in the last question into a single object. Print the object where you stored these objects.
Combine the three objects you created using the grade book data set in the last question into a single object. Print the object where you stored these objects.
In this section, insert a chunk of code to export the grade book data, the attendance data, the summary grade book, and the summary attendance as one Excel file. Make sure to name your data file something different than the Excel file that had the original data that you loaded into R for this assignment.
Enter the names of anyone one that assisted you with completing this lab. If no one helped you complete the assignment, just type out that no one helped you
Enter the names of anyone that you assisted with completing this lab. If you did not help anyone, then just type out that you didn’t help anyone.
Click the “Knit” button to publish your work as an html document. This document or file will appear in the folder specified by your working directory. You will need to upload both this RMarkdown file and the html file it produces to AsU Learn to get all of the lab points for this week. Additionally, you need to upload the Excel file that you exported when completing the assignment to get all of the lab points for this week.