An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20121017/26641fa5/attachment.pl>
vectors comparison
4 messages · Simon Knapp, Francesco Nutini
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, Francesco Nutini
<nutini.francesco at gmail.com> wrote:
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 this example only the -10 in position y[3] satisfies the criteria, because x has in position x[2]the figure 1.
Thank in advance for you help,Francesco
[[alternative HTML version deleted]]
______________________________________________ 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.
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20121017/b7384bf4/attachment.pl>
5 days later
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20121022/8c289663/attachment.pl>