Grade analysis R task | Sololearn: Learn to code for FREE!

0

Grade analysis R task

#Code not working input <- readLines('stdin') x <- as.integer(input[1]) dat <- data.frame("id" = c(1:10), "grade" = c(75, 26, 54, 90, 86, 93, 48, 71, 66, 99)) n <- c(dat[dat$grade>x]) print(length(n))

r

8/8/2022 11:13:53 AM

shiwana

2 Answers

New Answer

+2

shiwana There should be comma after > x you have to get length of grade n <- c(dat[dat$grade > x, ]) print(length(n$grade))

0

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,data$grade>x)["grade"]))) #It worked