Hi everyone,

I am attempting to bin a vector of numbers between 0 and 1 into intervals
of 0.001 but many values at the endpoints of the intervals are getting
binned into the wrong interval. For example, the first 3 rows are binned
incorrectly here:

library(Hmisc)
df=data.frame(x=c(0.308,0.422,0.174,0.04709))
df$bucket=cut2(df$x,seq(0,1,0.001),oneval=FALSE)
print(df)
        x        bucket
1 0.30800 [0.307,0.308)
2 0.42200 [0.421,0.422)
3 0.17400 [0.173,0.174)
4 0.04709 [0.047,0.048)

I have tried closing and reopening RStudio after clearing the workspace and
reinstalling the Hmisc package. I am running R version 3.0.2 on Windows 7
64-bit. Thank you.

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to