I need help with R software code! Please help me write a code that does the foll
ID: 3205498 • Letter: I
Question
I need help with R software code! Please help me write a code that does the following
1. Read in the data file, score.txt
2. Suppose our grading policy is: >= 90, A, 80~89, B, 70~79, C, 60~69, D, <60, F. Find the numbers of getting A, B, C, D, and F, based on Exam1.
3. Get a bar chart of grade distribution of Exam1.
score.txt sample
Gender Hw1 Hw2 Hw3 Hw4 Exam1 Exam2
F 9 9 10 10 92 90
F 8 10 10 0 43 56
M 10 7 6 9 71 94
M 8 9 6 10 70 93
M 9 8 10 10 95 100
M 8 9 10 10 91 94
F 6 5 10 6 37 65
F 6 5 10 10 50 63
M 8 10 10 10 94 73
M 6 7 9 5 62 76
M 8 8 8 7 83 79
M 7 8 10 10 92 95
F 10 9 10 10 77 53
F 9 8 6 8 64 76
F 7 6 10 10 56 60
F 8 10 9 10 76 60
F 10 9 10 10 86 75
F 8 9 10 10 81 93
Explanation / Answer
# I am only reading Exam1 data, as it is only required.
Exam1 <- c(92, 43, 71, 70, 95, 91, 37, 50, 94, 62, 83, 92, 77, 64, 56, 76, 86,81)
A=B=C=D=E=0
for(i in 1:length(Exam1)){
if(Exam1[i]>=90){
A=A+1
} else if(80<=Exam1[i]<=89){
B=B+1
} else if(70<=Exam1[i]<=79){
C=C+1
} else if(60<=Exam1[i]<=69){
D=D+1
} else{
E=E+1
}
}
?in
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.