Skip to content
Prev 318606 / 398503 Next

explanation of the problem..

HI Utpal,

Alight, I will look into it.? I was under the impression that this is what you wanted:

dat1<- structure(list(V1 = c(1L, 1L, 1L, 1L, 1L, 1L, 1L), V2 = c(1L,
1L, 1L, 1L, 1L, 1L, 0L), V3 = c(1L, 1L, 1L, 1L, 1L, 1L, 1L),
??? V4 = c(1L, 1L, 0L, 1L, 1L, 1L, 1L), V5 = c(1L, 1L, 1L, 1L,
??? 1L, 0L, 1L), V6 = c(1L, 1L, 1L, 0L, 1L, 1L, 1L), V7 = c(1L,
??? 1L, 1L, 1L, 1L, 1L, 1L), V8 = c(1L, 1L, 1L, 0L, 1L, 0L, 1L
??? ), V9 = c(1L, 0L, 1L, 1L, 1L, 1L, 1L), V10 = c(1L, 1L, 1L,
??? 1L, 1L, 1L, 1L), V11 = c(0L, 1L, 1L, 1L, 1L, 1L, 1L), V12 = c(1L,
??? 1L, 1L, 1L, 1L, 1L, 1L), V13 = c(1L, 1L, 1L, 1L, 1L, 1L,
??? 1L)), .Names = c("V1", "V2", "V3", "V4", "V5", "V6", "V7",
"V8", "V9", "V10", "V11", "V12", "V13"), class = "data.frame", row.names = c(NA,
-7L))
dat2<- dat1[,1:4]
?dat2[4,]<- c(3,2,3,1)
?dat2[6,]<- c(3,3,3,3)


?dat2
#? V1 V2 V3 V4
#1? 1? 1? 1? 1
#2? 1? 1? 1? 1
#3? 1? 1? 1? 0
#4? 3? 2? 3? 1
#5? 1? 1? 1? 1
#6? 3? 3? 3? 3
#7? 1? 0? 1? 1

res<-
 lapply(2:ncol(dat2),function(i) {x1<- 
combn(names(dat2),i);unlist(lapply(1:ncol(x1), function(i) {x2<- 
dat2[,x1[,i]];dim(x2[!as.logical(rowSums(x2==0)),])[1]}))})
res
#[[1]]
#[1] 6 7 6 6 5 6

#[[2]]
#[1] 6 5 6 5
#
#[[3]]
#[1] 5


A.K.
Message-ID: <1362253029.12820.YahooMailNeo@web142603.mail.bf1.yahoo.com>
In-Reply-To: <CALNdZWWsL7efLFyt9Va3tfFffEiek1oqheAif8rK50aLqxUtpQ@mail.gmail.com>