I would like to identify binary columns in a data.frame.
For example, this table
my.table <-read.table(text=\"a,b,c 0,2,0 0.25,1,1 1,0,0\", header
apply(my.table,2,function(x) { all(x %in% 0:1) })
(or
apply(my.table,2,function(x) { all(na.omit(x) %in% 0:1) })
if you want to allow for NA values)
NA