0

Your program needs to take a number as input, and output the number of students who have a grade greater than the given input.

Where is the error? It shows wrong output. 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) ) y <- data[data

quot;grade">x] print(length(y))

16th Sep 2021, 10:23 AM
Ammara Tayyab
5 Réponses
+ 3
If you don't want to use subset(), you can also subset by indexing, but mind it must be data[data$grade > x,] (no commas) To get the number of students, you can use *length()* on a *vector* Alternatively, you can count the number of rows in the remaining *dataframe* with *nrow(y)*
16th Sep 2021, 12:05 PM
Lisa
Lisa - avatar
+ 2
Ammara Tayyab Please review subset() y <- subset(data, grade >x) print(length(y$grade))
16th Sep 2021, 10:53 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 2
Rik Wittkopp Thank you. It worked.
16th Sep 2021, 10:56 AM
Ammara Tayyab
0
Simba Still shows error.
16th Sep 2021, 10:52 AM
Ammara Tayyab
0
Ammara Tayyab Please review before continuing. R has a steep learning curve, so advisable to be solid on the basics before continuing
16th Sep 2021, 11:00 AM
Rik Wittkopp
Rik Wittkopp - avatar