Grades Summary
Taak
Swipe to start coding
You have already created a factor vector, grades_f
, which assigns each numeric grade into one of five categories ('F'
, 'D'
, 'C'
, 'B'
, 'A'
). Your goal is to:
- Call the
summary()
function on yourgrades_f
variable to output the number of occurrences of each factor grade. - Divide those counts by the total number of grades, computed by calling
length()
function ongrades_f
variable, to obtain the relative frequency of each grade.
Oplossing
99
1
2
3
4
5
6
7
8
9
10
11
12
# Vector of grades
grades <- c(96,84,67,78,61,74,93,77,74,82,83,79,61,23,76,79,79,73,
75,81,65,85,29,79,70,76,75,80,66,72,88,87,86,93,70,88,
67,76,69,84,85,59,82,76,67,75,80,75,79,86)
# Cut the grades into five intervals
grades_f <- cut(grades, breaks = c(0, 60, 75, 85, 95, 100),
labels = c('F', 'D', 'C', 'B', 'A'),
ordered_result = T, right = F)
# Show the summary of grades
summary(grades_f)
# Calculate the proportion of each grade
summary(grades_f)/length(grades_f)
Was alles duidelijk?
Bedankt voor je feedback!
Sectie 3. Hoofdstuk 6
99
1
2
3
4
5
6
7
8
9
10
11
12
# Vector of grades
grades <- c(96,84,67,78,61,74,93,77,74,82,83,79,61,23,76,79,79,73,
75,81,65,85,29,79,70,76,75,80,66,72,88,87,86,93,70,88,
67,76,69,84,85,59,82,76,67,75,80,75,79,86)
# Cut the grades into five intervals
grades_f <- cut(grades, breaks = c(0, 60, 75, 85, 95, 100),
labels = c('F', 'D', 'C', 'B', 'A'),
ordered_result = T, right = F)
# Show the summary of grades
___(___)
# Calculate the relative frequency of each grade
___(___)/___(___)
Vraag AI
Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.