[R] Making random values which are binary numbers

Duncan Murdoch murdoch.duncan at gmail.com
Mon Dec 8 22:01:29 CET 2014


On 08/12/2014 6:25 AM, Frederic Ntirenganya wrote:
> Hi All,
>
> i would like to write a srcipt which ruturn the random numbers which are
> binary numbers.
>
> Example: The first group : 111111111
>                 second : 0000000000000
>                 third : 10101000011100
>
> in such away that i can make iterartions.

I'm not sure what you mean by the last part, but you can generate binary 
data using rbinom:

firstgroup <- rbinom(9, size=1, prob=0.999)
second <- rbinom(13, size=1, prob=0.001)
third <- rbinom(14, size=1, prob=0.5)

Duncan Murdoch
>
>
> Frederic Ntirenganya
> Maseno University,
> African Maths Initiative,
> Kenya.
> Mobile:(+254)718492836
> Email: fredo at aims.ac.za
> https://sites.google.com/a/aims.ac.za/fredo/
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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