Building on @Colonel Beauvel's answer,
A bin frequency table function. (Histogram table).
binFreqTable <- function(x, bins=5) {
freq = hist(x, breaks=bins, include.lowest=TRUE, plot=FALSE)
ranges = paste(head(freq$breaks,-1), freq$breaks[-1], sep=" - ")
return(data.frame(range = ranges, frequency = freq$counts))
}
Examples:
x <-c(0.01,0.34,0.45,0.67,0.89,0.12,0.34,0.45,0.23,0.45,0.34,0.32,0.45,0.21,0.55,0.66,0.99,0.23,.012,0.34)
binFreqTable(x,c(0,.3,.6,1)) # 3 bins split at 0.3 and 0.6
# range frequency
#1 0 - 0.3 6
#2 0.3 - 0.6 10
#3 0.6 - 1 4
binFreqTable(x,5) # Split into 5 even bins
# range frequency
#1 0 - 0.2 3
#2 0.2 - 0.4 8
#3 0.4 - 0.6 5
#4 0.6 - 0.8 2
#5 0.8 - 1 2
binFreqTable(x,seq(0,1,by=0.1)) # Split into 0.1 increments from 0 to 1
# range frequency
#1 0 - 0.1 2
#2 0.1 - 0.2 1
#3 0.2 - 0.3 3
#4 0.3 - 0.4 5
#5 0.4 - 0.5 4
#6 0.5 - 0.6 1
#7 0.6 - 0.7 2
#8 0.7 - 0.8 0
#9 0.8 - 0.9 1
#10 0.9 - 1 1