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

8th Aug 2022, 11:13 AM
shiwana
shiwana - avatar
2 Réponses
+ 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))
8th Aug 2022, 1:20 PM
A͢J
A͢J - avatar
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
8th Aug 2022, 4:52 PM
shiwana
shiwana - avatar