[R] How to change several elements of an array simultaneously?

Peter Holzer holzer at stat.math.ethz.ch
Mon Jan 17 12:01:29 CET 2000


I have a matrix `m' and two vectors `rs' and `cs'. I want to change m at the
positions (rs[1], cs[1]), (rs[2], cs[2]), ... to 1. Obviously I can do that by

> m[rs + (cs-1) * dim(m)[1]] <- 1

but I would just be interested whether I am missing a more "intuitive" way
of doing that.

Thanks in advance, Peter

____________________________________________________________

Peter Holzer                      phone: + 41 1 632 46 34
Seminar fuer Statistik, LEO C14   fax:   + 41 1 632 12 28
(Leonhardstr. 27)                  <holzer at stat.math.ethz.ch>
ETH (Federal Inst. Technology)
8092 Zurich                       http://www.stat.math.ethz.ch/~holzer/
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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