Although not as brief as Kenneth's solution ;-) but my brief answer would
be:

cumsum(na.omit(long))

Kind regards,

-Mark-


2013/5/28 Kenneth B Vaughn <vaughn@phxlaw.com>

>
> Sent from my BlackBerry 10 smartphone on the Verizon Wireless 4G LTE
> network.
>   *From: *Martin Bauer
> *Sent: *Tuesday, May 28, 2013 12:30 AM
> *To: *r-sig-finance@r-project.org
> *Subject: *[R-SIG-Finance] row sum in XTS object
>
> Hi,
>
> here my code
>
> require(quantmod)
> indexes<-c("XLB","XLE","XLF","XLI","XLK","XLP","XLU","XLV","XLY")
> getSymbols(indexes)
>
>
> p=cbind(Ad(XLB),Ad(XLE),Ad(XLF),Ad(XLI),Ad(XLK),Ad(XLP),Ad(XLU),Ad(XLV),Ad(XLY))
>
> XLB.CCI=CCI(p[,1],10)
> XLE.CCI=CCI(p[,2],15)
> XLF.CCI=CCI(p[,3],16)
> XLI.CCI=CCI(p[,4],22)
> XLK.CCI=CCI(p[,5],28)
> XLP.CCI=CCI(p[,6],32)
> XLU.CCI=CCI(p[,7],9)
> XLV.CCI=CCI(p[,8],6)
> XLY.CCI=CCI(p[,9],10)
>
>
> p.CCI=cbind(XLB.CCI,XLE.CCI,XLF.CCI,XLI.CCI,XLK.CCI,XLP.CCI,XLU.CCI,XLV.CCI,XLY.CCI)
>
>
> long=lag(p.CCI,k=1)*ROC(p,type="discrete",n=1)
> charts.PerformanceSummary(long,ylog=TRUE,main="TEST")
>
> How can I now sum each column now in the object long, keeping the day and
> just addsum (p.CCI*ROC)
>
> Any idea ?
>
> Many thanks
>
>
> _______________________________________________
> R-SIG-Finance@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions
> should go.
>

	[[alternative HTML version deleted]]

