[R] Simple - Finding vector in a vector
Mike Spam
ichmagspam at googlemail.com
Mon Oct 8 15:12:24 CEST 2012
Hey Rui,
Perfect! Thanks!! :)
Nico
2012/10/8 Rui Barradas <ruipbarradas at sapo.pt>:
> Hello,
>
> See ?rle
>
> Hope this helps,
>
> Rui Barradas
> Em 08-10-2012 13:55, Mike Spam escreveu:
>>
>> Hi,
>>
>> just a simple question.
>> Assumed i have a vector,
>>
>> FALSE TRUE TRUE TRUE FALSE TRUE FALSE TRUE FALSE
>> or
>> NA 1 1 1 NA 1 NA 1 NA
>>
>> what i need is the position where an element is the same - three (or
>> in general multiple) times in a row.
>>
>> in this case: i want to get the position where it is TRUE TRUE TRUE or 1 1
>> 1
>> it doesn't matter if it is the first, middle or last element. So the
>> output could be 2 or 3 or 4
>>
>> My idea would be to lag the vector and calc differences... but i would
>> prefer any build in (or time saving) function. :)
>>
>> thanks,
>>
>> Nico
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
>
More information about the R-help
mailing list