You can try mtabulatefrom the qdapTools package:
library(qdapTools)
head(mtabulate(as.data.frame(t(df))))
There are, of course, many other options.
For example, cSplit_efrom my splitstackshape package (with a flaw that is inefficient, you must first insert the values together before you can separate them):
library(splitstackshape)
library(dplyr)
As units and zeros:
df %>%
mutate(combined = apply(., 1, function(x) paste(na.omit(x), collapse = ","))) %>%
cSplit_e("combined", ",", mode = "binary", type = "character", fill = 0) %>%
select(starts_with("combined_")) %>%
head
As initial values:
df %>%
mutate(combined = apply(., 1, function(x) paste(na.omit(x), collapse = ","))) %>%
cSplit_e("combined", ",", mode = "value", type = "character", fill = "") %>%
select(starts_with("combined_")) %>%
head
"reshape2":
library(reshape2)
## The values
dcast(melt(as.matrix(df), na.rm = TRUE),
Var1 ~ value, value.var = "value")
## ones and zeroes
dcast(melt(as.matrix(df), na.rm = TRUE),
Var1 ~ value, value.var = "value", fun.aggregate = length)