> Thanks for help! > However, changing the index from i to j for the column vector changes the > output. I would like the matrix to be the following:> -1 1 0 0 0 0 0 > 0 -1 1 0 0 0 0 > 0 0 -1 1 0 0 0 > ..... > etc.> How to code it?as Enrico Schumann showed you: Without any loop, a very nice R-ish way (see his message)! Martin> Best, > Maija
Thanks, but I didn't quite get it. And I don't get it running as it should. ti 7. elok. 2018 klo 10.47 Martin Maechler (maechler at stat.math.ethz.ch) kirjoitti:> > > Thanks for help! > > However, changing the index from i to j for the column vector changes the > > output. I would like the matrix to be the following: > > > -1 1 0 0 0 0 0 > > 0 -1 1 0 0 0 0 > > 0 0 -1 1 0 0 0 > > ..... > > etc. > > > How to code it? > > as Enrico Schumann showed you: Without any loop, a very nice > R-ish way (see his message)! > > Martin > > > Best, > > Maija > >[[alternative HTML version deleted]]
Hello, If it is not running as you want it, you should say what went wrong. Post the code that you have tried and the expected output, please. (In fact, the lack of expected output was the reason why my suggestion was completely off target.) Rui Barradas On 07/08/2018 09:20, Maija Sirkj?rvi wrote:> Thanks, but I didn't quite get it. And I don't get it running as it should. > > ti 7. elok. 2018 klo 10.47 Martin Maechler (maechler at stat.math.ethz.ch > <mailto:maechler at stat.math.ethz.ch>) kirjoitti: > > > > Thanks for help! > > However, changing the index from i to j for the column vector > changes the > > output. I would like the matrix to be the following: > > > -1 1 0 0 0 0 0 > > 0 -1 1 0 0 0 0 > > 0 0 -1 1 0 0 0 > > ..... > > etc. > > > How to code it? > > as Enrico Schumann showed you: Without any loop, a very nice > R-ish way (see his message)! > > Martin > > > Best, > > Maija >