Re: [R] conditional replacement of contiguous values

2010-10-08 Thread Henrique Dallazuanna
Try this: replace(have, mapply(seq, which(have), which(have) + 3), TRUE) On Fri, Oct 8, 2010 at 2:07 PM, andrewjt wrote: > > Hello, > I need help getting from data$HAVE to data$NEED (see below). This requires > replacing every TRUE in data$HAVE with 4 TRUE(s) in data$NEED. > > Any ideas? It see

[R] conditional replacement of contiguous values

2010-10-08 Thread andrewjt
Hello, I need help getting from data$HAVE to data$NEED (see below). This requires replacing every TRUE in data$HAVE with 4 TRUE(s) in data$NEED. Any ideas? It seems straight forward but I can't figure it out! Thanks in advance HAVE NEED 1 FALSE FALSE 2 FALSE