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))5 Answers
+ 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)*
+ 2
Ammara Tayyab
Please review subset()
y <- subset(data, grade >x)
print(length(y$grade))
+ 2
Rik Wittkopp
Thank you. It worked.
0
Simba
Still shows error.
0
Ammara Tayyab
Please review before continuing.
R has a steep learning curve, so advisable to be solid on the basics before continuing