-3

I have an exercise that tells me to do if the lessons are more than 5.0. I must take the students who passed the lessons to do it as bar chart. enter image description here

this is the Data_passed image.I want to make students and the grade bar chart

I did that barplot(table(student$d_grade)) but it says me student didn't find.

dataframe :

Data_passed <- structure(list(student = c(21118, 21118, 21118, 21118, 21118, 21118), course = c("C2", "C5", "C3", "C1", "C4", "C7"), year = c(2013, 2013, 2013, 2013, 2013, 2013), exam = c("F1", "F1", "F2", "F1", "S1", "S1"), grade = c(7, 7.5, 7.5, 5.8, 8.2, 6.5), d_grade = c("Good", "Very Good", "Very Good", "Medium", "Very Good", "Good")), row.names = c(NA, -6L), class = c("tbl_df", "tbl", "data.frame"))
ThomasIsCoding
  • 96,636
  • 9
  • 24
  • 81
ek.Nik
  • 185
  • 1
  • 8

1 Answers1

0

Maybe you can try this

barplot(table(Data_passed[c("student", "d_grade")]))

enter image description here

data

Data_passed <- structure(list(student = c(21118, 21118, 21118, 21118, 21118, 21118), course = c("C2", "C5", "C3", "C1", "C4", "C7"), year = c(2013, 2013, 2013, 2013, 2013, 2013), exam = c("F1", "F1", "F2", "F1", "S1", "S1"), grade = c(7, 7.5, 7.5, 5.8, 8.2, 6.5), d_grade = c("Good", "Very Good", "Very Good", "Medium", "Very Good", "Good")), row.names = c(NA, -6L), class = c("tbl_df", "tbl", "data.frame"))

ThomasIsCoding
  • 96,636
  • 9
  • 24
  • 81
  • Error in df[c("student", "d_grade")] : object of type 'closure' is not subsettable – ek.Nik May 25 '21 at 11:16
  • @maikl Please show your data by `dput(df)` – ThomasIsCoding May 25 '21 at 11:17
  • function (x, df1, df2, ncp, log = FALSE) { if (missing(ncp)) .Call(C_df, x, df1, df2, log) else .Call(C_dnf, x, df1, df2, ncp, log) } – ek.Nik May 25 '21 at 11:18
  • @maikl What's the name of your data? Use `dput` and copy/paste to your post. – ThomasIsCoding May 25 '21 at 11:19
  • function (x, file = "", control = c("keepNA", "keepInteger", "niceNames", "showAttributes")) { if (is.character(file)) if (nzchar(file)) { file <- file(file, "wt") on.exit(close(file)) } else file <- stdout() .Internal(dput(x, file, .deparseOpts(control))) } – ek.Nik May 25 '21 at 11:21
  • @maikl No, that's not your data. Read https://stackoverflow.com/a/5963610/12158757 – ThomasIsCoding May 25 '21 at 11:24
  • @maikl what's the name of your data frame? – ThomasIsCoding May 25 '21 at 11:28
  • Data_passed is the dataframe – ek.Nik May 25 '21 at 11:30
  • @maikl then run `dput(Data_passed)`, and copy/paste the output to your post. – ThomasIsCoding May 25 '21 at 11:31
  • @ThomaslsCoding I do it. but it was too much so I can't put it all – ek.Nik May 25 '21 at 11:37
  • @maikl We can use part of it, e.g., `dput(head(Data_passed))` – ThomasIsCoding May 25 '21 at 11:40
  • structure(list(student = c(21118, 21118, 21118, 21118, 21118, 21118), course = c("C2", "C5", "C3", "C1", "C4", "C7"), year = c(2013, 2013, 2013, 2013, 2013, 2013), exam = c("F1", "F1", "F2", "F1", "S1", "S1"), grade = c(7, 7.5, 7.5, 5.8, 8.2, 6.5), d_grade = c("Good", "Very Good", "Very Good", "Medium", "Very Good", "Good")), row.names = c(NA, -6L), class = c("tbl_df", "tbl", "data.frame")) – ek.Nik May 25 '21 at 11:40