Re: [R] NOT-SO-SIMPLE function!

2008-06-02 Thread T.D.Rudolph
I am continually amazed at how many ways there are to skin a cat in R! Gabor Grothendieck wrote: > > In the following cs increases by 1 for each nonzero > entry in x. Thus the zeros plus the preceding nonzero > form runs in cs. seq(cs)-match(cs,cs) assigns 0 > to the first element of each suc

Re: [R] NOT-SO-SIMPLE function!

2008-06-02 Thread Gabor Grothendieck
In the following cs increases by 1 for each nonzero entry in x. Thus the zeros plus the preceding nonzero form runs in cs. seq(cs)-match(cs,cs) assigns 0 to the first element of each such run, 1 to the next, 2 to the next and so on. Thus shifting it forward and adding 1 gives the number of prece

Re: [R] NOT-SO-SIMPLE function!

2008-06-02 Thread Gabor Grothendieck
In the following cs increases by 1 for each nonzero entry in x. Thus the zeros plus the preceding nonzero form runs in cs. seq(cs)-match(cs,cs) assigns 0 to the first element of each such run, 1 to the next, 2 to the next and so on. Thus shifting it forward and adding 1 gives the number of prece

Re: [R] NOT-SO-SIMPLE function!

2008-06-02 Thread Moshe Olshansky
NA -1.0986123 [10] NA NA NA NA -0.2231436 0.000 --- On Tue, 3/6/08, Moshe Olshansky <[EMAIL PROTECTED]> wrote: > From: Moshe Olshansky <[EMAIL PROTECTED]> > Subject: Re: [R] NOT-SO-SIMPLE function! > To: "T.D.Rudolph" &

Re: [R] NOT-SO-SIMPLE function!

2008-06-02 Thread Moshe Olshansky
000 NA -1.0986123 NA -0.4054651 NA NA -1.3862944 [10] NA NA NA NA -0.4054651 -0.6931472 --- On Tue, 3/6/08, Marc Schwartz <[EMAIL PROTECTED]> wrote: > From: Marc Schwartz <[EMAIL PROTECTED]> > Subject: Re: [R] NOT-SO-

Re: [R] NOT-SO-SIMPLE function!

2008-06-02 Thread T.D.Rudolph
You are absolutely correct Marc; thank you for making this assumption! While it will take some time for me to rightfully understand the logical ordering of your proposed function, it certainly seems to produce the result I was looking for, and economically at that. rle is indeed highly useful

Re: [R] NOT-SO-SIMPLE function!

2008-06-02 Thread Marc Schwartz
on 06/02/2008 01:30 PM T.D.Rudolph wrote: I am trying to set up a function which processes my data according to the following rules: 1. if (x[i]==0) NA 2. if (x[i]>0) log(x[i]/(number of consecutive zeros immediately preceding it +1)) The data this will apply to include a variety of whole num

[R] NOT-SO-SIMPLE function!

2008-06-02 Thread T.D.Rudolph
I am trying to set up a function which processes my data according to the following rules: 1. if (x[i]==0) NA 2. if (x[i]>0) log(x[i]/(number of consecutive zeros immediately preceding it +1)) The data this will apply to include a variety of whole numbers not limited to 1 & 0, a number of which