df2 <- data.frame(Mean = c(.5,4,2.3,1.2,3.7,3.3,.8), Numbers = \"NA\")
for(i in 1:length(df2$Mean)){
if(df2$Mean[i] <= .5) {
df2$Number[i] = 0
df$Number <- findInterval( df$Mean, c( seq(0.5, 3.5, by=1) , Inf) )
There was an edge case where df$Mean = 3.5 that was not covered by your definition. My method gives it a 4.
The findInterval function is really doing something very similar to the cut function, except it returns a numeric value rather that a factor. It sets up a bunch of intervals and tells you which interval each item would fall into.