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))6 ответов
+ 1
#You may try this code , it is working for me .
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)
)
# Here is the new code i added
#To count number of rows you can use
data <- subset(data,grade>x)
nrow(data)
+ 3
index the elements of grade which are > x, then get the length of the indexed vector.
alternatively, subset the data frame and leave only the rows with grade > x. Then count the number of rows.
+ 2
No, I won't complete the program. Please show your code. If you search for R on Q&A you can get ideas how other users solved it
+ 2
It is not helpful to just give a ready-made code without explanation
0
Can you please complete the program here? Lisa
I didn't understand
0
Okay thanks