comparison histogram.r @ 8:a889861139bc draft

Uploaded
author guerler
date Thu, 17 Apr 2014 17:56:42 -0400
parents 2e2d92b2ae38
children 656efffe650e
comparison
equal deleted inserted replaced
7:2e2d92b2ae38 8:a889861139bc
1 # utilities
2 roundUp <- function(x) 10^ceiling(log10(x))
3 roundDown <- function(x) 10^floor(log10(x))
4
5 # wrapper
1 wrapper <- function(table, columns, options) { 6 wrapper <- function(table, columns, options) {
2 7
3 # initialize output list 8 # initialize output list
4 l <- list() 9 l <- list()
5 10
16 21
17 # get min/max boundaries 22 # get min/max boundaries
18 max_value <- max(unlist(m)) 23 max_value <- max(unlist(m))
19 min_value <- min(unlist(m)) 24 min_value <- min(unlist(m))
20 25
26 # round number to base 10
27 min_value <- roundUp(min_value)
28 max_value <- roundUp(max_value)
29
30 # identify increment
31 increment <- (max_value - min_value) / 10
32
21 # fix range and bins 33 # fix range and bins
22 bin_seq = seq(min_value, max_value, by=10) 34 bin_seq = seq(min_value, max_value, by=increment)
23 35
24 # add as first column 36 # add as first column
25 l <- append(l, list(bin_seq[2: length(bin_seq)])) 37 l <- append(l, list(bin_seq[2: length(bin_seq)]))
26 38
27 # loop through all columns 39 # loop through all columns