There is a new book on (Perl and) R for computational biology,
G. Valiente. Combinatorial Pattern Matching Algorithms in
Computational Biology using Perl and R. Taylor & Francis/CRC Press
(2009)
http://www.crcpress.com/product/isbn/9781420063677
I hope it will be of much use to R developer
Is there any built-in way to lexicographically compare two vectors of
the same length in R? The textbook algorithm could be coded as follows:
lex.cmp <- function (vec1,vec2) {
for (j in 1:length(vec1)) {
if (vec1[j] < vec2[j]) { return(-1) }
if (vec1[j] > vec2[j]) { return(1) }
}
Deleting a row from a matrix turns it into a vector (and dim names
are lost) if the resulting matrix has only one row or column. For
instance:
> x <- matrix(1:10, ncol=2)
> x <- x[1,]
turns x into
[1] 1 6
instead of
[,1] [,2]
[1,]16
Is there any way to force the result to
3 matches
Mail list logo