[R] Newbie needs to count elements in a row
Henrique Dallazuanna
wwwhsd at gmail.com
Tue Dec 29 14:52:54 CET 2009
Try this:
rowSums(!is.na(x))
On Tue, Dec 29, 2009 at 11:49 AM, Verena Weber <VerenaWeber at gmx.de> wrote:
> Hi,
>
> I have a n*m matrix and would like to count the number of elements not equal to NA in a ROW.
>
> e.g.
>
> x 1 2 3 NA 10
> y 2 NA 8 9 NA
>
> Which function can I use to obtain
> "4" for row x and
> "3" for row y?
>
> Could you help me? I found some functions for columns but not for rows...
>
> Thank you very much!
>
> ______________________________________________
> 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
More information about the R-help
mailing list