Suppose I have some count data that looks like this:
library(tidyr) library(dplyr) X.raw <- data.frame( x = as.factor(c(\"A\", \"A\", \"A\", \"B\", \
You could explicitly make all possible combinations and then joining it with the tidy summary:
x.fill <- expand.grid(x=unique(x.tidy$x), x=unique(x.tidy$y)) %>% left_join(x.tidy, by=("x", "y")) %>% mutate(count = ifelse(is.na(count), 0, count)) # replace null values with 0's