[R] new book on (Perl and) R for computational biology

2009-05-08 Thread Gabriel Valiente
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

[R] lexicographic comparison of two vectors

2008-05-12 Thread Gabriel Valiente
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) } }

[R] when deleting a row from a matrix gives a vector

2007-11-02 Thread Gabriel Valiente
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