search for: itslength

Displaying 1 result from an estimated 1 matches for "itslength".

Did you mean: tslength
2007 Aug 24
4
Turning a logical vector into its indices without losing its length
I have the code below which gives me what I want for temp based on logvec but I was wondering if there was a shorter way ( i.e : a one liner ) without having to initialize temp to zeros. This is purely for learning purposes. Thanks. logvec <- c(TRUE,FALSE,FALSE,TRUE,FALSE,FALSE,TRUE,FALSE) temp<-numeric(length(invec)) temp[invec]<-which(invec) temp [1] 1 0 0 4 0 0 7 0 obviously, the