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))

15th Sep 2021, 9:06 AM
Ammara Tayyab
6 Respostas
+ 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)
18th Sep 2021, 8:49 AM
Meghna Joseph George
+ 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.
15th Sep 2021, 9:43 AM
Lisa
Lisa - avatar
+ 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
15th Sep 2021, 4:50 PM
Lisa
Lisa - avatar
+ 2
It is not helpful to just give a ready-made code without explanation
18th Sep 2021, 9:37 AM
Lisa
Lisa - avatar
0
Can you please complete the program here? Lisa I didn't understand
15th Sep 2021, 3:04 PM
Ammara Tayyab
0
Okay thanks
15th Sep 2021, 5:00 PM
Ammara Tayyab