[R] Efficient Binning
    Dan Abner 
    dan.abner99 at gmail.com
       
    Fri Jul 14 16:10:59 CEST 2017
    
    
  
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 complicated
with the embedded curly braces. Is there a more efficient (i.e., easier)
way to go about this?
boundaries<-(0:16)/16
rand<-runif(1)
Which bin number (1:16) does rand fall in?
Thanks,
Dan
	[[alternative HTML version deleted]]
    
    
More information about the R-help
mailing list