Skip to content
Prev 302069 / 398503 Next

sub setting a data frame with binomial responses

If I understand you correctly you want to exclude columns where all successes equal trials, all successes equal 0, or successes are a mixture of trials and 0 with no in between values. You did not make it clear if the number of trials can vary, but in your example they do not. Given that all three criteria can be consolidated into a single statement:
x2 = c(5, 5, 5, 5), x3 = c(0, 0, 0, 0), x4 = c(5, 0, 5, 0)), 
  .Names = c("n", "x1", "x2", "x3", "x4"), row.names = c(NA, -4L), 
  class = "data.frame")
n x1 x2 x3 x4
1 5  2  5  0  5
2 5  3  5  0  0
3 5  1  5  0  5
4 5  3  5  0  0
n x1
1 5  2
2 5  3
3 5  1
4 5  3

----------------------------------------------
David L Carlson
Associate Professor of Anthropology
Texas A&M University
College Station, TX 77843-4352