0

Anybody fix this code?

You have a dataframe that includes grades of students. Your program needs to take a number as input, and output the number of students who have a grade greater than the given input. For example, for the input 89, the output should be: [1] 3 as 3 students have grades greater than 89.

4th Apr 2023, 6:42 AM
Grace Johnruz Imperial
2 Antworten
+ 4
Please tag the relevant programming language, not "grade". Do not re-post the same question. If you want to add anything, post in your existing thread. https://www.sololearn.com/Discuss/3203871/?ref=app
4th Apr 2023, 6:49 AM
Lisa
Lisa - avatar
0
input <- readLines('stdin') x <- as.integer(input[1]) data <- data.frame( "id" = c(1:10), "grade" = c(75, 26, 54, 90, 86, 93, 48, 71, 66, 99) ) student <- 0 for ( i in data$grade){ if ( i > x ){ student <- 1 + student } } print(student)
4th Apr 2023, 6:43 AM
Grace Johnruz Imperial