Try this:

replace(have, mapply(seq, which(have), which(have) + 3), TRUE)

On Fri, Oct 8, 2010 at 2:07 PM, andrewjt <atrant@mun.ca> 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 seems straight forward but I can't figure it out!
> Thanks in advance
>
>
>  HAVE             NEED
>
> 1  FALSE          FALSE
> 2  FALSE          FALSE
> 3  TRUE           TRUE
> 4  FALSE          TRUE
> 5  FALSE          TRUE
> 6  FALSE          TRUE
> 7  FALSE          FALSE
> 8  FALSE          FALSE
> 9  FALSE          FALSE
> 10 TRUE          TRUE
> 11 FALSE         TRUE
> 12 FALSE         TRUE
> 13 FALSE         TRUE
> --
> View this message in context:
> http://r.789695.n4.nabble.com/conditional-replacement-of-contiguous-values-tp2968727p2968727.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help@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.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

	[[alternative HTML version deleted]]

