Skip to content
Back to formatted view

Raw Message

Message-ID: <979BC2E1-0A2C-4B16-A924-CF4DAB69BA5A@licht-malerei.de>
Date: 2009-01-25T22:02:50Z
From: Jörg Groß
Subject: comparing the previous and next entry of a vector to a criterium

Hi,

I have a quit abstract problem, hope someone can help me here.

I have a vector like this:


  x <- c(1,2,3,4,5,2,6)
  x

[1] 1 2 3 4 5 2 6

now I want to get the number where the previous number is 1 and the  
next number is 3
(that is the 2 at the second place)

I tried something with tail(x, -1) ...
with that, I can check  the next number, but how can I check the  
previous number?