+ 5

Can anyone help me in the code coach problem 3?

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) ) print(length(t(subset(data, grade > input)["grade"]))) Now my question, Why it isn't working??

7th Sep 2021, 10:56 AM
ÃÑSHÙ KHÁÑRÂ
ÃÑSHÙ KHÁÑRÂ - avatar
3 Answers
+ 3
ANSHU KHANRA | Solohelper Very little mistake. There should be (grade > x) instead of (grade > input) Here is another solution: y = data[data$grade > x, ] print(length(y$grade))
7th Sep 2021, 11:50 AM
A͢J
A͢J - avatar
+ 6
AJ - SoloHelper Thank you.!!
8th Sep 2021, 6:21 AM
ÃÑSHÙ KHÁÑRÂ
ÃÑSHÙ KHÁÑRÂ - avatar
+ 2
use the converted x, not the raw input. Also, there is no need to transpose a vector for getting its length
7th Sep 2021, 11:32 AM
Lisa
Lisa - avatar