matrixStats
matrixStats copied to clipboard
rowDuplicated() and rowAnyDuplicated()
This issue is a question / feature request.
Do you think it would make sense to add functions like duplicated()
and anyDuplicated()
optimized to work on every row/column to this package?
I was looking for this today...
matrixStats
is primarily intended for numerical operations on matrices, not dataframe-like operations such as duplicated()
. Besides, it would only work reliably for integer matrices because double matrices suffer from floating point imprecision.
matrixStats
is primarily intended for numerical operations on matrices, not dataframe-like operations such asduplicated()
. Besides, it would only work reliably for integer matrices because double matrices suffer from floating point imprecision.
It could have a tolerance parameter that defaults to sqrt(.Machine$double.eps)
like all.equal()
. There are many numerical operations where being able to detect duplicated vectors (or close to duplicated vectors) would be useful.
@yaccos I would not be quick to agree that duplicated()
is a data.frame-like operation. Sure it works on entries of data.frame but it is also used to test if there are repeating values in a vector - this use is what I have in mind here.
We can easily have matrices of counts or ranks. matrixStats
itself has rowRanks()
and rowCounts()
. Then checking if there are duplicates in rows/columns might be necessary. Non-parametric tests such as Mann-Whitney test is one example.