Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lära Grades Summary | Factors
R Introduction: Part I

book
Grades Summary

Uppgift

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:

  1. Call the summary() function on your grades_f variable to output the number of occurrences of each factor grade.
  2. Divide those counts by the total number of grades, computed by calling length() function on grades_f variable, to obtain the relative frequency of each grade.

Lösning

# 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)
Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 3. Kapitel 6
single

single

# 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
___(___)/___(___)

Fråga AI

expand

Fråga AI

ChatGPT

Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal

some-alt