What the breaks are is that you are looking to see where the NAs
start. In your case, you wanted the value at the start of the NA
string to be grouped with the following NAs. The 'is.na' will return
TRUE for NAs and if you invert the vector, you will have TRUE for each
of the non-NA values. By d
Just so. I got until 'split' but was stuck on how to get the breaks ...
Thank you!
Joh
jim holtman wrote:
> Is this what you want:
>
>> testVector <- c(12,32,NA,NA,56,NA,78,65,87,NA,NA,NA,90)
>> # get the breaks at the NAs
>> xb <- cumsum(!is.na(testVector))
>> split(seq(length(testVector)
Is this what you want:
> testVector <- c(12,32,NA,NA,56,NA,78,65,87,NA,NA,NA,90)
> # get the breaks at the NAs
> xb <- cumsum(!is.na(testVector))
> split(seq(length(testVector)), xb)
$`1`
[1] 1
$`2`
[1] 2 3 4
$`3`
[1] 5 6
$`4`
[1] 7
$`5`
[1] 8
$`6`
[1] 9 10 11 12
$`7`
[1] 13
On Wed, O
3 matches
Mail list logo