I have same trouble with the package dplyr. My data set has 3 varaibles; ID= number of individuum, Exp=number of Experiment, Zone= zone wihtin the test vessel (1 top 2 centre 3 bottom). I try to count the observation of the data which I grouped by ID and Exp and it works with the below equation.
x<-data%>%
group_by(ID,Exp)%>%
count(Zone)
What the problem is, when one ID was not within Zone 1 than the new dataset will not display this, of course because there are no observation to count. What I try to do now is, to insert a "which" opperator to say the function, "if you do not count a observation within zone 1 (or 2 or 3) set the value 0". Has someone an idea how to fix my problem?
Thanks!