Ciao, I have two columns. Every row represents one student. The first column tells what class the student is in. The second column tells if the student passed a exam.
Here is my replicating example. This is the data I have now:
a=c("A","A","A","A","B","B","B","C","C")
b=c(0,0,1,0,0,0,0,1,1)
mydata=data.frame(a,b)
names(mydata)=c("CLASS","PASSED")
This is the data I seek to attain:
a1=c("A","B","C")
b1=c(4,3,2)
c1=c(1,0,2)
mydataWANT=data.frame(a1,b1,c1)
names(mydataWANT)=c("CLASS","SIZE","PASSED")
Here is my attempt for the dplyr package
mydataWANT <- data.frame(mydata %>%
group_by(CLASS,PASSED) %>%
summarise(N = n()))
yet it does not yield the desire output.