[R] Sum results in a matrix

R. Michael Weylandt michael.weylandt at gmail.com
Tue Mar 13 17:31:30 CET 2012


res3 + t(res3)

Michael

On Tue, Mar 13, 2012 at 8:15 AM, RMSOPS <ricardosousa2000 at clix.pt> wrote:
> Hello,
>     With the following code get the results array
> res3<-table(df$v_source,df$v_destine)
>
>  1  2  3  4  5  6  7
>  1  0 10  0  0  0  0  0
>  2 11  0  0  0  0  0  0
>  3  0  0 18 15  0  0  0
>  4  0  0 15 11  0  0  0
>  5  0  0  0  0  1  0  0
>  6  0  0  0  0  0  1  0
>  7  0  0  0  0  0  0 18
>
>
> my idea was to create a new table of results from res3 but making the sum of
> the results where the position of the origin and destination were reversed.
>
>    for example
>         [1,2]= 10
>          [2,1]=11
>
>  New Table Final.
>  points         result
>  [1 and 2]    21
>
> thanks
>
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Sum-results-in-a-matrix-tp4468936p4468936.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.



More information about the R-help mailing list