Re: [R] using nrow to identify one row

From: Henrique Dallazuanna <wwwhsd_at_gmail.com>
Date: Fri, 14 Mar 2008 17:52:56 -0300

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 <gregory_gentlemen_at_yahoo.ca> 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:
>
> 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 am indexing the rows of large matrices according to another variable and I need to test when the resulting matrices have 0, 1 or more rows.
>
> Thanks in advance for any assistance.
>
> Best regards,
> Gregory Gentlemen
>
>
>
>
> ---------------------------------
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Fri 14 Mar 2008 - 20:55:51 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 14 Mar 2008 - 21:30:21 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive