[R] Creating a frequency table for binomial varaible

Rui Barradas ruipbarradas at sapo.pt
Wed Nov 21 16:48:17 CET 2012


Hello,

Try

table(x)  # or table(dat$value)

Hope this helps,

Rui Barradas
Em 21-11-2012 13:19, arun4 escreveu:
> Hello,
> I have simulated 30  observations from a binomial(5,0.1) distribution.
> Now I need to make frequency table( that means I need to tally how many 0's
> , 1's  2's....... 5's)
> I know that the simple  R function table() will do this, but I am afraid
> that some times I may get zero frequency for some particular values (for
> example in the above there are 5-0's 10-1's , 14-2's, 10-3's , 11-4's but no
> any 5's )
>
> So I want to make by frequecy table ( as a date frame) as
> value   freq
> 0           5
> 1          10
> 2          14
> 3          10
> 4           11
> 5           0
>
>
> How can I create such a table?
> Forgive me if this is a very basic question. I am new to R.
>
> Thank you very much.
>
>
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Creating-a-frequency-table-for-binomial-varaible-tp4650286.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.




More information about the R-help mailing list