Re: [R] Best way to store negative indexes

2004-07-28 Thread Peter Dalgaard
StephaneDemurget <[EMAIL PROTECTED]> writes: > Hi, > > I'm trying to figure out how to properly construct a graph of > frequencies of a difference between 2 values, that is | i | - | j |. > I'd like to know the best way to store the actual data because of > course doing my_vector[i -j] will not w

RE: [R] Best way to store negative indexes

2004-07-27 Thread Liaw, Andy
Can you give a simple example of what you are trying to do? Would the following help? > x <- sample(10) > diffMat <- outer(x, x, "-") > x [1] 1 10 5 8 9 6 3 2 4 7 > diffMat [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,]0 -9 -4 -7 -8 -5 -2 -1 -3-6

Re: [R] Best way to store negative indexes

2004-07-27 Thread Adaikalavan Ramasamy
Do you mean something like abs( my_vector[i] - my_vector[j] ) See if reading help("subset") helps. On Wed, 2004-07-28 at 01:42, StephaneDemurget wrote: > Hi, > > I'm trying to figure out how to properly construct a graph of > frequencies of a difference between 2 values, that is | i | - | j

[R] Best way to store negative indexes

2004-07-27 Thread StephaneDemurget
Hi, I'm trying to figure out how to properly construct a graph of frequencies of a difference between 2 values, that is | i | - | j |. I'd like to know the best way to store the actual data because of course doing my_vector[i -j] will not work because the index could be negative. I know there's