RE: [R] Count all dataset

From: Liaw, Andy <andy_liaw_at_merck.com>
Date: Sat 19 Mar 2005 - 11:22:43 EST


Here are two (pretty much the same) ways:

> d

  x1 x2 x3
1 D D A
2 B D A
3 C A <NA>
4 D D A
5 A D C
> table(sapply(d, as.character))

A B C D
5 1 2 6
> table(as.matrix(d))

A B C D
5 1 2 6
> sum(is.na(d))

[1] 1

HTH,
Andy

> From: Jan Sabee
>
> Dear all R member,
>
> I have a dataset which looks like:
>
> x1 x2 . . . x250
> A A C
> A C C
> A A A
> A A <NA>
> B B B
> <NA> C B
> ...
> more 2000 rows.
>
> I need count all dataset at the following:
>
> A = sum of A
> B = sum of B
> C = sum of C
> <NA> = sum of <NA>
>
> What function can I use?
> I'm just a beginner in R programming.
>
> Best regards,
> Jan Sabee
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>
>
>



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sat Mar 19 11:28:14 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:30:51 EST