conditions
on y must be true":
which(x==1 & (c(0,y[1:12])==-10 |c(0,0, y[1:11])==-10|
c(0,0,0, y[1:10])==-10))
thank in advance for you help,
Francesco
> Date: Wed, 17 Oct 2012 10:36:46 +1100
> Subject: Re: [R] vectors comparison
> From: sleepingw...@gmail.c
Dear Simon Knapp,
sorry the -500 is a typo.Nice job, your code works perfectly!Thanks a lot!
> Date: Wed, 17 Oct 2012 10:36:46 +1100
> Subject: Re: [R] vectors comparison
> From: sleepingw...@gmail.com
> To: nutini.france...@gmail.com
> CC: r-help@r-project.org
>
> Your q
Your question does not seem to make sense - there is no value of -500
in Y (did you mean -10?). Anyway, I think this might work:
which(y==-10 & (x==1 | c(0, x[-length(x)]) == 1 | c(x[-1], 0) == 1))
... though one would think there is a more elegant way
On Wed, Oct 17, 2012 at 10:07 AM, Francesc
Dear R-Users,
I'd like to have your help on this problem:
I have two vectors:x<- c(0,1,0,0,0,0,0,0,0,0,0,1,0)y<-
c(0,0,-10,0,0,-10,0,-10,0,0,0,0,0)
And I want to know where the value -500 in y have a correspondence value 1 in
x.Considering a buffer of one position before and after in x.i.e. in t
4 matches
Mail list logo