[R] Efficient Binning

Jeff Newmiller jdnewmil at dcn.davis.ca.us
Fri Jul 14 17:50:26 CEST 2017


cut( 0.51, boundaries )

You can also use as.integer to convert the resulting factor to an integer. 
Sent from my phone. Please excuse my brevity.

On July 14, 2017 7:10:59 AM PDT, Dan Abner <dan.abner99 at gmail.com> wrote:
>Hi all,
>I have a situation where I have 16 bins. I generate a random number and
>then want to know which bin number the random number falls in. Right
>now, I
>am using a serious of 16 if() else {} statements which get very
>with the embedded curly braces. Is there a more efficient (i.e.,
>way to go about this?
>Which bin number (1:16) does rand fall in?
>	[[alternative HTML version deleted]]
>R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>PLEASE do read the posting guide
>and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list