Clangon Clangon - 10 months ago 66
R Question

Histogram in R when using a binary value

I have data of students from several schools. I want to show a histogram of the percentage of all students that passed the test in each school, using R.
My data looks like this (id,school,passed/failed):

432342 school1 passed

454233 school2 failed

543245 school1 failed


(The point is that I am only interested in the percent of students that passed, obviously those that didn't passed have failed. I want to have one column for each school that shows the percent of the students in that school that passed)


Answer Source

there are many ways to do that. one is:


p<-aggregate(df$result=="passed"~school, mean, data=df)