[R] Summing using a boolean index vector (repost in plain text).

jim holtman jholtman at gmail.com
Fri Jun 18 18:23:32 CEST 2010


?cumsum
?ave

 But without data (follow the posting guide) specific solution can not
be specified

On Fri, Jun 18, 2010 at 11:39 AM, Dan Stanger <DStanger at eatonvance.com> wrote:
> Hello all:
> I have a dataframe f of weekdays and value, and a Boolean vector with Fridays set to true, and other days set to false, created by fridays<-(diff(f$weekdays) < -1).
> I would like to create a vector of sums, for each week.  That is, start summing on the first false value in the vector, and when I get to true, produce the sum, and start summing again.
> Is there a vector operation which can do this, without writing an explicit loop?
> Thank you,
> Dan Stanger
> P.S. Sorry about the repost.
> Eaton Vance Management
> 200 State Street
> Boston, MA 02109
> 617 598 8261
>
> ______________________________________________
> 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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?



More information about the R-help mailing list