Re: [R] Merging Matrices
To clarify, the two matrices might look like this: A B C D E F A 1 2 3 4 5 6 B 2 4 6 8 10 12 C 0 0 0 0 0 0 D 0 1 0 1 0 1 E 3 6 9 11 13 15 F 2 2 2 2 2 2 B D E B 4 9 13 D 9 8 7 E 1 0 1 I would like this: A B C D E F A 1 2 3 4 5 6 B 2 8 6 17 23 12 C 0 0 0 0 0 0 D 0 10 0 9 7 1 E 3 7 9 11 14 15 F 2 2 2 2 2 2 Thanks. -- View this message in context: http://n4.nabble.com/Merging-Matrices-tp1605474p1636943.html Sent from the R help mailing list archive at Nabble.com. __ R-help@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.
[R] Merging Matrices
I have two symmetric matrices, but of different dimensions. The entries are identified by specific labels some of which are shared by both matrices. I would like to sum the two matrices, but retain the union of the two. In other words, I want the result to be the same size as the larger of the two matrices, but with the entries that they share added together. cbind() and rbind() don't work since the matrices are different sizes (symmetrically). Merge doesn't want to cooperate, although it might be because I can't understand the documentation. I tried the package reshape but didn't get very far with that either. I tried simply adding (+) them, but that was a stupid first try. Any help is appreciated! -- View this message in context: http://n4.nabble.com/Merging-Matrices-tp1605474p1605474.html Sent from the R help mailing list archive at Nabble.com. __ R-help@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.
[R] Using indexing to manipulate data
I know one of R's advantages is it's ability to index, eliminating the need for control loops to select relevant data, so I thought this problem would be easy. I can't crack it. I have looked through past postings, but nothing seems to match this problem I have a data set with one column of actors and one column of acts. I need a list that will give me a pair of actors in each row, provided they both participated in the act. Example: The Data looks like this: Jim A BobA BobC Larry D Alice C Tom F Tom D Tom A Alice B NancyB I would like this: Jim Bob Jim Tom Bob Alice Larry Tom AliceNancy The order doesn't matter (Jim-Bob vs. Bob-Jim), but each pairing should be counted only once. Thanks! -- View this message in context: http://n4.nabble.com/Using-indexing-to-manipulate-data-tp1597547p1597547.html Sent from the R help mailing list archive at Nabble.com. __ R-help@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.