Hi Jörg,
If I understood,
apply(yourdataframe,2,function(x) x[diff(which(x==1 | x==3))])
should do what you want.
HTH,
Jorge
On Sun, Jan 25, 2009 at 5:53 PM, Jörg Groß wrote:
> is there a way to do that without generating a data.frame?
>
> In my real data, I have a big data.frame and I have
How about:
a <- c(1,2,3,3,2,1,6,3,2)
b <- c(NA,a[-length(a)])
c <- c(a[-1],NA)
a[b==1 & c==3]
[1] 2 6
hth,
Kingsford Jones
On Sun, Jan 25, 2009 at 3:02 PM, Jörg Groß wrote:
> Hi,
>
> I have a quit abstract problem, hope someone can help me here.
>
> I have a vector like this:
>
>
> x <- c(1
The data frame is not essential. I was just trying to keep things tidy.
Try this:
nxt <- c(tail(x, -1), NA)
prv <- c(NA, head(x, -1))
x[nxt == 3 & prv == 1]
On Sun, Jan 25, 2009 at 5:53 PM, Jörg Groß wrote:
> is there a way to do that without generating a data.frame?
>
> In my real data, I hav
on 01/25/2009 04:29 PM Jörg Groß wrote:
> 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
> (t
Try this:
> DF <- data.frame(x, nxt = c(tail(x, -1), NA), prv = c(NA, head(x, -1)))
> DF
x nxt prv
1 1 2 NA
2 2 3 1
3 3 4 2
4 4 5 3
5 5 2 4
6 2 6 5
7 6 NA 2
> subset(DF, nxt == 3 & prv == 1)$x
[1] 2
On Sun, Jan 25, 2009 at 5:29 PM, Jörg Groß wrote:
> Hi,
>
> I have a
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
On 25-Jan-09 22:29:25, Jörg Groß wrote:
> 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
is there a way to do that without generating a data.frame?
In my real data, I have a big data.frame and I have to compare over
different columns...
Am 25.01.2009 um 23:42 schrieb Gabor Grothendieck:
Try this:
DF <- data.frame(x, nxt = c(tail(x, -1), NA), prv = c(NA, head(x,
-1)))
DF
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,
9 matches
Mail list logo