Skip to content
Back to formatted view

Raw Message

Message-ID: <28BA6768-1DFC-43BF-927C-83AA046CD61A@comcast.net>
Date: 2012-09-28T04:28:54Z
From: David Winsemius
Subject: How to test if there is a subvector in a longer vector
In-Reply-To: <7953BA1D7779E746994B38A00362416C0B31E700@exch-mbx-02.utu.fi>

On Sep 27, 2012, at 2:00 PM, Atte Tenkanen wrote:

> Hi,
> 
> There are certainly several ways to test, whether a longer vector includes a subvector. 
> For instance, c(1,4,6) is included in c(2,1,1,4,6,3). How to test this and which would be the fastest way to do it?
> 

> all( c(1,4,6) %in% c(2,1,1,4,6,3) )
[1] TRUE


-- 
David Winsemius, MD
Alameda, CA, USA