[R] Extracting/setting elements from/in a matrix/array
Laurent Gautier
laurent at genome.cbs.dtu.dk
Mon Dec 31 14:28:18 CET 2001
Dear all,
I had to extracts/set elements from/in a matrix. Let say I have two
vectors dim1 and dim2 of indices in the respective two dimensions of a
matrix: I want to extract all the corresponding elements. I the case of a
nxn matrix, dim1 <- 1:n and dim2 <- 1:n would extract the diagonal.
I know one way would be to use the functions 'row' and 'col', but the
matrixes I have are can be rather large. This is probably a detail but
I was looking for something that would avoid be bit more memory
friendly... I have made functions for that purpose but I suspect somebody
already did something (which would be in R, but I could not find it...).
For the sake of avoiding duplication of similar things (hence making code
more readable), I would be happy to replace it in my code.
Does anybody knows if such things already exists ?
Laurent
Laurent Gautier CBS, Building 208, DTU
PhD. Student D-2800 Lyngby,Denmark
tel: +45 45 25 24 85 http://www.cbs.dtu.dk/laurent
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list