Getting same output as cut() using speedier hist() or findInterval()?
问题 I read this article http://www.r-bloggers.com/comparing-hist-and-cut-r-functions/ and tested hist() to be faster than cut() by ~4 times on my PC. My script loops through cut() many times so the time-saving would be significant. I thus tried to switch to the speedier function but am having difficulties getting the exact output as per cut() . From the sample code below: data <- rnorm(10, mean=0, sd=1) #generate data my_breaks <- seq(-6, 6, by=1) #create a vector that specifies my break points