Re: [R] Identifying one or more TRUE in the middle of an array

2014-06-08 Thread William Revelle
Yet another way which returns the row and column of the items you want rc - which(t(x[,-c(1,ncol(x))]),arr.ind=TRUE) #this identifies the rows and columns but is one column off rc[,1] - rc[,1] +1 #this adjusts the columns colnames(rc) - c(col,row) rc #show them Bill On Jun 6, 2014, at

[R] Identifying one or more TRUE in the middle of an array

2014-06-06 Thread Fisher Dennis
R 3.1.0 OS X Colleagues I have an array (I am using T/F rather than TRUE/FALSE for convenience) that could have patterns like: c(T, T, T, F, F, F, T, F, T, T, T) ## T at either end, a single T in the middle c(F, F, F, F, F, T, F, F, T, T, T) ## T at

Re: [R] Identifying one or more TRUE in the middle of an array

2014-06-06 Thread Peter Langfelder
Not sure if this is better than your brute force and you may be able to simplify it... notStart = function(x) { n = length(x) i0 = which(x); n0 = length(i0); i0!=c(1:n)[1:n0]; } notStartNorEnd = function(x) { which(x)[notStart(x) rev(notStart(rev(x)))] } notStartNorEnd(c(F, F, F))

Re: [R] Identifying one or more TRUE in the middle of an array

2014-06-06 Thread ONKELINX, Thierry
Here is my solution. falses - which(!x) first.false - head(falses, 1) last.false - tail(falses, 1) which(x[first.false:last.false]) + first.false - 1 Best regards, ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest team Biometrie