Grade Analysis R program . Can you please help me to solve this problem. Thanks in Advance | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Grade Analysis R program . Can you please help me to solve this problem. Thanks in Advance

You have a dataframe that includes grades of students. Your program needs to take a number as input, and output the number of students who have a grade greater than the given input. For example, for the input 89, the output should be: [1] 3 as 3 students have grades greater than 89.

22nd Sep 2021, 5:55 AM
MD Mehedi Hasan
MD Mehedi Hasan - avatar
12 Answers
+ 9
print(length(data$grade[data$grade > x ]))
24th Sep 2021, 1:27 PM
David García Prados
+ 4
This is only the code that it is already given. Hint: * subset the grade column so that you only keep keep the grade > x * get the length of the remaining vector
22nd Sep 2021, 7:11 AM
Lisa
Lisa - avatar
+ 4
print(length(t(subset(data, grade>x)["grade"])))
18th Feb 2022, 2:06 PM
Wong Tsz Fung
+ 2
MD Mehedi Hasan This is not your code. where is your attempts?
22nd Sep 2021, 7:47 AM
A͢J
A͢J - avatar
+ 2
It's corrected now. It should work fine.
5th Oct 2021, 7:43 AM
SUNDAY Amos
SUNDAY Amos - avatar
+ 1
Hi, please link your code so we can help you!
22nd Sep 2021, 6:27 AM
Lisa
Lisa - avatar
+ 1
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) )
22nd Sep 2021, 6:46 AM
MD Mehedi Hasan
MD Mehedi Hasan - avatar
+ 1
SUNDAY Amos No, shouldn't work, R is case-sensitive
5th Oct 2021, 7:40 AM
Lisa
Lisa - avatar
+ 1
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"])))
8th Aug 2022, 11:46 AM
shiwana
shiwana - 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) ) pet <- subset(data, grade>x) Print(length(pet$grade)) #Should work fine.😉
5th Oct 2021, 7:36 AM
SUNDAY Amos
SUNDAY Amos - avatar
0
@SUNDAY Amos line 9, lower case P not capitol
19th Jan 2022, 2:23 AM
Javier Franco
Javier Franco - 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"])))
17th Oct 2022, 1:46 AM
Ahmed Mu'azu Sabo
Ahmed Mu'azu Sabo - avatar