Re: [R] using nrow to identify one row

2008-03-14 Thread Gabor Csardi
Try temp[1,,drop=FALSE] See ?"[" for the explanation. Gabor On Fri, Mar 14, 2008 at 04:46:10PM -0400, Gregory Gentlemen wrote: > Hi fellow R-users, > > I have run into a problem when trying to identify the number of rows in a > matrix. Say we have an arbitrary 5 by 5 matrix called temp: > >

Re: [R] using nrow to identify one row

2008-03-14 Thread Henrique Dallazuanna
nrow is for number of rows in matrix/data.frame, here you can use: NROW(temp[1,]) length(temp[1,]) But if you want the index of row try this: unique(row(temp)[1,]) On 14/03/2008, Gregory Gentlemen <[EMAIL PROTECTED]> wrote: > Hi fellow R-users, > > I have run into a problem when trying to iden

[R] using nrow to identify one row

2008-03-14 Thread Gregory Gentlemen
Hi fellow R-users, I have run into a problem when trying to identify the number of rows in a matrix. Say we have an arbitrary 5 by 5 matrix called temp: temp <- matrix(norm(25), nrow=5) The problem is that nrow(temp[1,]) returns NULL. I would like it to return 1 because in my larger program I