title: Error: (subscript) logical subscript too long
body: <p>Can some one let me know why I am getting this error and how I can fix it? </p>
  
  <p>Here is the code </p>
  
  <p>What I am trying to do is remove the rows that associated 1's if the column of that one's less than 10</p>
  
  <pre><code>a0=rep(1,40)
  a=rep(0:1,20)
  b=c(rep(1,20),rep(0,20))
  c0=c(rep(0,12),rep(1,28))
  c1=c(rep(1,5),rep(0,35))
  c2=c(rep(1,8),rep(0,32))
  c3=c(rep(1,23),rep(0,17))
  c4=c(rep(1,6),rep(0,34))
  x=matrix(cbind(a0,a,b,c0,c1,c2,c3,c4),nrow=40,ncol=8)
  nam &lt;- paste("V",2:9,sep="")
  colnames(x)&lt;-nam
  dat &lt;- cbind(y=rnorm(40,50,7),x)
  #===================================
  toSum &lt;- colSums(dat)
  Col &lt;- Val &lt;- NULL
  for(i in 1:length(toSum)){
  if(toSum[i]&lt;10){
  Col &lt;- c(Col,colnames(dat)[i])
  Val &lt;- c(Val,toSum[i])}
  }
  cs &lt;- colSums(dat) &lt; 10
  indx &lt;- dat[,which(cs)]==0
  for(i in 1:dim(indx)[2]){
  datnw &lt;- dat[indx[,i],]
  dat &lt;- datnw}
  datnw2 &lt;- dat[, -which(cs)]
  </code></pre>
  
  <p>Thanks</p>