Re: [R] subsetting a matrix and filling other

2006-11-07 Thread Christos Hatzis
Use a list to store the partial matrices: z - vector(list, 189) for(i in 1:189) z[[i]] - subset(...) -Christos -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of antonio rodriguez Sent: Tuesday, November 07, 2006 2:01 PM To: R-Help Subject: [R]

Re: [R] subsetting a matrix and filling other

2006-11-07 Thread antonio rodriguez
Christos Hatzis escribió: Use a list to store the partial matrices: z - vector(list, 189) for(i in 1:189) z[[i]] - subset(...) Hi Christos, I've tried it but it died unexpectedly with a (Killed) message and the linux console prompt again. I think I have enough memory (512) and a

Re: [R] subsetting a matrix and filling other. Solved

2006-11-07 Thread antonio rodriguez
antonio rodriguez escribió: Christos Hatzis escribió: Use a list to store the partial matrices: z - vector(list, 189) for(i in 1:189) z[[i]] - subset(...) Hi Christos, I've tried it but it died unexpectedly with a (Killed) message and the linux console prompt again. I think I

Re: [R] Subsetting a matrix without for-loop

2006-01-30 Thread Gabor Grothendieck
The result is linear in A so its a matter of finding the matrix to multiply it by: matrix(c(rep(1,3), rep(0,7)), 3, 9, byrow = TRUE) %*% A On 1/30/06, Camarda, Carlo Giovanni [EMAIL PROTECTED] wrote: Dear R-users, I'm struggling in R in order to squeeze a matrix without using a for-loop.

Re: [R] Subsetting a matrix without for-loop

2006-01-30 Thread jim holtman
use 'filter': x - matrix(1:100,10) x [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,]1 11 21 31 41 51 61 71 8191 [2,]2 12 22 32 42 52 62 72 8292 [3,]3 13 23 33 43 53 63 73 8393 [4,]4 14 24 34 44

Re: [R] Subsetting a matrix without for-loop

2006-01-30 Thread Petr Pikal
Hi matrix(colSums(embed(A,3)[1:3,]),3,6, byrow=T)[3:1,] [,1] [,2] [,3] [,4] [,5] [,6] [1,]6 33 60 87 114 141 [2,]9 36 63 90 117 144 [3,] 12 39 66 93 120 147 will do it. However I am not sure if it is quicker than your for loop. HTH Petr On 30 Jan 2006

Re: [R] subsetting a matrix

2003-09-30 Thread Thomas W Blackwell
Rajarshi - Why not simply subscript your matrix X to return the rows and columns you want to keep ? For example, new - X[16:176, c(3,5,7,9)] assuming those are the rows and columns you want. See help(Extract). - tom blackwell - u michigan medical school - ann arbor - On Tue, 30 Sep

RE: [R] subsetting a matrix

2003-09-30 Thread Ted Harding
On 30-Sep-03 Rajarshi Guha wrote: Hi, I'm trying to take a set of rows and columns out of a matrix. I hve been using the index aray approach. My overll matrix is X and is 179 x 65. I want to take out 4 columns and 161 rows. Thus I made a 161 x 2 array I and filled it up with the row,col

Re: [R] subsetting a matrix

2003-09-30 Thread Jason Turner
(Ted Harding) wrote: On 30-Sep-03 Rajarshi Guha wrote: Hi, I'm trying to take a set of rows and columns out of a matrix. I hve been using the index aray approach. My overll matrix is X and is 179 x 65. I want to take out 4 columns and 161 rows. ... This is documented in An Introduction to R,

Re: [R] subsetting a matrix

2003-09-30 Thread Rajarshi Guha
On Tue, 2003-09-30 at 15:51, Jason Turner wrote: (Ted Harding) wrote: On 30-Sep-03 Rajarshi Guha wrote: Hi, I'm trying to take a set of rows and columns out of a matrix. I hve been using the index aray approach. My overll matrix is X and is 179 x 65. I want to take out 4 columns and

Re: [R] Subsetting a matrix [Again!]

2003-07-15 Thread Achim Zeileis
On Tuesday 15 July 2003 12:14, Ted Harding wrote: Hi Folks, People's suggestion of drop=FALSE seemed to do the trick (preserving matrix character when subestting to a row, i.e. creating 1xk matrix). However, I seem to have encountered a case where even this does not work: mu-c(1,2,3)

Re: [R] Subsetting a matrix [Again!]

2003-07-15 Thread Ted Harding
On 15-Jul-03 Achim Zeileis wrote: [...] mu1-mu[iX1,drop=FALSE]; mu2-mu[iX2,drop=FALSE]; mu1 [1] 1 mu2 [1] 2 3 So now I still don't get my 1xk matrices, even though mu is a matrix and I've used drop=FALSE. Why? Because you are subsetting mu like a vector not like a matrix. The

Re: [R] Subsetting a matrix

2003-07-14 Thread Ted Harding
On 14-Jul-03 Adelchi Azzalini wrote: Personally, I find this automatic conversion to vector a somewhat confusing feature (although I can see its reasons), and I know of many people that would have preferred that drop=FALSE was the default behaviour, but surely now is difficult to change

Re: [R] Subsetting a matrix

2003-07-14 Thread Ted Harding
On 14-Jul-03 Adelchi Azzalini wrote: Maybe it is reasonable to propose incorporating drop as one of the things you can set with options? :-- [...] Perhaps this is a way-out. As usual, everything is feasible when we resort entirely on our own code. The danger is that we might make use of