# HG changeset patch # User guerler # Date 1397843405 14400 # Node ID 656efffe650e2ce803c150272206233ac1591b75 # Parent a889861139bc518a0c7723592d347b74ad1c5ea2 Uploaded diff -r a889861139bc -r 656efffe650e histogram.r --- a/histogram.r Thu Apr 17 17:56:42 2014 -0400 +++ b/histogram.r Fri Apr 18 13:50:05 2014 -0400 @@ -24,15 +24,22 @@ min_value <- min(unlist(m)) # round number to base 10 - min_value <- roundUp(min_value) + min_value <- roundDown(min_value) max_value <- roundUp(max_value) + # check if single bin is enough + if (min_value == max_value) { + l <- append(l, max_value) + l <- append(l, 1.0) + return (l) + } + # identify increment - increment <- (max_value - min_value) / 10 + increment <- roundUp((max_value - min_value) / 10) # fix range and bins bin_seq = seq(min_value, max_value, by=increment) - + # add as first column l <- append(l, list(bin_seq[2: length(bin_seq)]))