This is a demonstration of an R package library(myPackage) that I am in the process of developing. The purpose of this package was two-fold:
For each course I teach my syllabus states that for those absences that are documented, the student will receive a value of “-1” as a place holder grader. This is to avoid the confusion of assigning a grade between 0 to 100. For students without a noted absence their cell remains empty, and when transcribed into R, it is read as “NA.”
When I process the grades for the final exam the first thing I do is convert “-1” to “NA” and “NA” to “0” in order to remove the exempt students from the assessment and assign a grade of 0 to those who did not have a noted absence. Therefore myPackage contains two things:
new.grades that takes a vector of length (n) and returns another vector of length (n) that translates “NA” to “0” and “-1” to “NA.”Grades of term test grades from a past statistics course that is stripped of any identifiable information.reweighted that will re-weighted the grading scheme for “NA” cases based on the remaining components in the course.library(myPackage)
head(Grades)
#> Term Test 1 (/505) Term Test 1 Adjust (/50) Term Test 2 (/57)
#> 1 34 36 40
#> 2 36 38 42
#> 3 26 28 29
#> 4 45 47 48
#> 5 18 20 -1
#> 6 34 36 40
#> Term Test 2 Adjust (/55)
#> 1 40
#> 2 42
#> 3 29
#> 4 48
#> 5 -1
#> 6 40
attach(Grades)The first variable consists of the unadjusted term test 1 grades (TT1) (out of 50) for a third year statistics course. Since every student either took the term test, or had a documented absence, the vector does not contain any “NAs.”
TT1=`Term Test 1 (/505)`
tail(TT1, 20)
#> [1] 36 43 41 20 -1 40 36 29 40 41 23 36 34 23 32 37 22 17 39 43The following command will transform the last 20 variables that were displayed for the unadjusted TT1 grades.
TT1_new=new.grades(TT1)
tail(TT1_new, 20)
#> [1] "36" "43" "41" "20" "NA" "40" "36" "29" "40" "41" "23" "36" "34" "23" "32"
#> [16] "37" "22" "17" "39" "43"This presents the numbers as a string. In order to work with the variables in any kind of quantitative analysis, I would have to use build in functions in base R such as the as.numeric function.