Thanks Henrique.

On Wed, Jul 28, 2010 at 9:20 PM, Henrique Dallazuanna [via R] <
[email protected]<ml-node%[email protected]>
> wrote:

> You've tried:
>
> diff(c(0, x)) ?
>
> On Wed, Jul 28, 2010 at 3:10 PM, Raghu <[hidden 
> email]<http://user/SendEmail.jtp?type=node&node=2305552&i=0>>
> wrote:
>
> > Hi
> >
> > I have say a large vector of 3500 digits. Initially the digits are 0s and
>
> > 1s. I need to check for a rule to change some of the 0s to -1s in this
> > vector. But once I change a 0 to -1 then I need to start applying the
> rule
> > to change the next 0 only after I see the next 1 in the vector.
> >
> > Say for example x = (0,0,0,0,0,0,0,1,0,0,1,1,0,0,1,0,0,0,1)
> > I need to traverse from the 9th element to the last ( because the first
> > occurrence of 1 is at 8) . Let us assume that according to our rule we
> > change the 13th element (only 0s can be changed) to -1. Now we need to go
>
> > to
> > the next occurrence of 1 (which is 15) and begin the rule application
> from
> > the 16th till the end of the vector and once replaced a 0 to a -1 then
> > start
> > again from the next 1. How do we code this? I 'feel' recursion is the
> best
> > possible solution but I am not a programmer and will await experts'
> views.
> > If this is not a typical R-forum question then my advance apologies.
> >
> > Many thx
> > --
> > 'Raghu'
> >
> >        [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > [hidden email] 
> > <http://user/SendEmail.jtp?type=node&node=2305552&i=1>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]]
>
>
> ______________________________________________
> [hidden email] <http://user/SendEmail.jtp?type=node&node=2305552&i=2>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.
>
>
> ------------------------------
>  View message @
> http://r.789695.n4.nabble.com/how-to-code-it-tp2305489p2305552.html
> To start a new topic under R help, email
> [email protected]<ml-node%[email protected]>
> To unsubscribe from R help, click here< (link removed) >.
>
>
>


-- 
'Raghu'

-- 
View this message in context: 
http://r.789695.n4.nabble.com/how-to-code-it-tp2305489p2305587.html
Sent from the R help mailing list archive at Nabble.com.

        [[alternative HTML version deleted]]

______________________________________________
[email protected] 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.

Reply via email to