0
|
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
|
5
|
16 count_sum <- sum(hist_data$counts)
|
|
17 if (count_sum > 0) {
|
|
18 hist_data$counts=hist_data$counts/count_sum
|
|
19 }
|
0
|
20
|
|
21 # collect vectors in list
|
|
22 l <- append(l, list(hist_data$breaks[2: length(hist_data$breaks)]))
|
|
23 l <- append(l, list(hist_data$counts))
|
|
24 }
|
|
25
|
|
26 # make sure length is fine
|
|
27 n <- max(sapply(l, length))
|
|
28 ll <- lapply(l, function(X) {
|
6
|
29 c(as.character(X), rep('2147483647', times = n - length(X)))
|
0
|
30 })
|
|
31 l <- do.call(cbind, ll)
|
|
32
|
|
33 # return
|
|
34 return (l)
|
|
35 }
|