changeset 9:656efffe650e draft

Uploaded
author guerler
date Fri, 18 Apr 2014 13:50:05 -0400
parents a889861139bc
children 86068f6de925
files histogram.r
diffstat 1 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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)]))