[R] summing up a matrix

Michael Dewey lists at dewey.myzen.co.uk
Fri Nov 18 16:42:26 CET 2016


Dear Matthias

It is rather hard to read that since you posted in HTML which scrambles 
things but I think

?cumsum

may help and possibly

?apply

as you seem to want to work by rows.

On 18/11/2016 15:16, Matthias Weber wrote:
> Hello together,
>
> is it possible, to summing up a matrix?
> I have the following matrix at the moment:
>
>                                 [,1]         [,2]         [,3]        [,4]         [,5]         [,6]
> 2016-11                20            200        100         50           100         30
> 2016-12                100          200        100         50           100         30
> 2017-01                50            200        100         50           100         30
>
> Now I want to summing up the matrix in a new matrix.
>
> The result should look like the following:
>
>                                 [,1]         [,2]         [,3]        [,4]         [,5]         [,6]
> 2016-11                20            220        320         370         470         500
> 2016-12                100          300        400         450         550         580
> 2017-01                50            250        350         400         500         530
>
> Is it possible, to create that?
>
> Thanks for your help.
>
> Best regards.
>
> Mat
>
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
>

-- 
Michael
http://www.dewey.myzen.co.uk/home.html



More information about the R-help mailing list