0
What's my wrong
I solved code project of section 3 but it seems doesn't work properly? 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) ) x <- (subset(data, grade> input)) print(length(x[,1]))
4 Answers
+ 1
Greater than x NOT input
x <- (subset(data, grade > x))
+ 1
ChaoticDawg but why not "input"?
Works with "input" too.
+ 1
Vasiliy
Both the value of 'grade' and 'x' are of type integer. This way works without implicit type conversion. At least I believe that is what the issue may be. IDK for sure yet, haven't fully tested.
+ 1
Absolutely right! "input" is a string variable, so we convert it to an integer by assigning it to the variable x: x <- as.integer (input [1]) If you don't do this, then comparing a number with a string we will not get exactly what we expect.