+ 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??
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))
+ 6
AJ - SoloHelper
Thank you.!!
+ 2
use the converted x, not the raw input. Also, there is no need to transpose a vector for getting its length