Hi, I have a matrix like this, two columns: a, b a b c1 21 c2 19 c2 20 c2 20 c4 25 c5 18 c5 18 how to prepare a new matrix removing the rows with repeated units in b columns, like there are two 20 and two 18 in b column (others are unique in b col). I wanna a pure matrix with one 20 and one 18. Thanks a lot! Yan [[alternative HTML version deleted]]
R. Michael Weylandt
2011-Oct-31 20:14 UTC
[R] how to remove the redundant rows of a matrix
Your data didn't come through with the html stripping but either unique() or duplicated() should get you where you need to be. Michael On Mon, Oct 31, 2011 at 12:25 PM, yan liu <yanliusun at gmail.com> wrote:> Hi, > > I have a matrix like this, two columns: a, b > > ?a b ?c1 21 ?c2 19 ?c2 20 ?c2 20 ?c4 25 ?c5 18 ?c5 18 > how to prepare a new matrix removing the rows with repeated units in b > columns, like there are two 20 and two 18 in b column (others are unique in > b col). ?I wanna a pure matrix with one 20 and one 18. > > Thanks a lot! > > Yan > > ? ? ? ?[[alternative HTML version deleted]] > > ______________________________________________ > 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. >
Reasonably Related Threads
- Selecting rows of a matrix based on some condition on the columns
- RFC: sapply() limitation from vector to matrix, but not further
- Counting similar rows
- [LLVMdev] [Polly] GSoC Proposal: Reducing LLVM-Polly Compiling overhead
- ?to calculate sth for groups defined between points in one variable (string), / value separating/ spliting variable into groups by i.e. between start, NA, NA, stop1, start2, NA, stop2