Re: [Rpy] matrix updating using rpy2

2009-02-22 Thread Laurent Gautier
And I forget one thing: computing the 1-D index from the row and column is also straightforward. # --- import rpy2.robjects as ro row_i = 1 col_i = 2 idx = (row_i-1) + m.dim[0] * (col_i - 1) m = ro.r.matrix(ro.IntVector(range(9)), nrow=3, ncol=3) m[idx] = 33 print(m) # --- L. Laurent

Re: [Rpy] matrix updating using rpy2

2009-02-22 Thread Laurent Gautier
The code snippet I gave was incorrect: # --- import rpy2.robjects as ro import rpy2.rlike.container as rlc m = ro.r.matrix(range(9), nrow=3, ncol=3) print(m) idx = rlc.TaggedList([ro.IntVector([1, ]), ro.IntVector([2, ])]) m2 = m.assign(idx, 33) print(m2) idx = rlc.Tagged

Re: [Rpy] matrix updating using rpy2

2009-02-21 Thread Sancar Adali
If I modify the code in the following way m = ro.r['matrix'](range(4), nrow=2, ncol=2) idx = ro.IntVector([1,4]) m2 = m.assign(idx, 33) print(m2) I get the following matrix [,1] [,2] [1,] 33 2 [2,] 133 I think the indices are like vector indices here, a single index, In

Re: [Rpy] matrix updating using rpy2

2009-02-21 Thread Laurent Gautier
Sancar Adali wrote: > I'm trying to access and update a particular element of a matrix to update it > > for example in R, > > mat=matrix(0,nrow=2,ncol=2) > mat[0,0]= mat[0,0]+1 In R, vector indexing starts at one; zero are silently ignored. > How do I do this in rpy2 > do I have to use the low-

[Rpy] matrix updating using rpy2

2009-02-20 Thread Sancar Adali
I'm trying to access and update a particular element of a matrix to update it for example in R, mat=matrix(0,nrow=2,ncol=2) mat[0,0]= mat[0,0]+1 How do I do this in rpy2 do I have to use the low-level interface or can I use high-level interface -- Sancar Adali Johns Hopkins University Graduate