comparison histogram.r @ 0:8fefbbf372be draft

Uploaded
author guerler
date Thu, 17 Apr 2014 11:16:28 -0400
parents
children cbdd329ab623
comparison
equal deleted inserted replaced
-1:000000000000 0:8fefbbf372be
1 wrapper <- function(table, columns, options) {
2
3 # initialize output list
4 l <- list()
5
6 # loop through all columns
7 for (key in names(columns)) {
8 # load column data
9 column <- as.numeric(columns[key])
10 column_data <- sapply( table[column], as.numeric )
11
12 # create hist data
13 hist_data <- hist(column_data, plot=FALSE)
14
15 # normalize densities
16 hist_data$counts=hist_data$counts/sum(hist_data$counts)
17
18 # collect vectors in list
19 l <- append(l, list(hist_data$breaks[2: length(hist_data$breaks)]))
20 l <- append(l, list(hist_data$counts))
21 }
22
23 # make sure length is fine
24 n <- max(sapply(l, length))
25 ll <- lapply(l, function(X) {
26 c(as.character(X), rep("", times = n - length(X)))
27 })
28 l <- do.call(cbind, ll)
29
30 # return
31 return (l)
32 }