annotate histogram.r @ 2:001c5e3e5517 draft

Uploaded
author guerler
date Mon, 31 Mar 2014 17:22:25 -0400
parents
children 39ee947b4a9e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
001c5e3e5517 Uploaded
guerler
parents:
diff changeset
1 wrapper <- function(table, columns, options) {
001c5e3e5517 Uploaded
guerler
parents:
diff changeset
2
001c5e3e5517 Uploaded
guerler
parents:
diff changeset
3 # initialize output list
001c5e3e5517 Uploaded
guerler
parents:
diff changeset
4 l <- list()
001c5e3e5517 Uploaded
guerler
parents:
diff changeset
5
001c5e3e5517 Uploaded
guerler
parents:
diff changeset
6 # loop through all columns
001c5e3e5517 Uploaded
guerler
parents:
diff changeset
7 for (key in names(columns)) {
001c5e3e5517 Uploaded
guerler
parents:
diff changeset
8 # load column data
001c5e3e5517 Uploaded
guerler
parents:
diff changeset
9 column <- as.numeric(columns[key])
001c5e3e5517 Uploaded
guerler
parents:
diff changeset
10 column_data <- sapply( table[column], as.numeric )
001c5e3e5517 Uploaded
guerler
parents:
diff changeset
11
001c5e3e5517 Uploaded
guerler
parents:
diff changeset
12 # create hist data
001c5e3e5517 Uploaded
guerler
parents:
diff changeset
13 hist_data <- hist(column_data, plot=FALSE)#, breaks=seq(by=options$bin_size))
001c5e3e5517 Uploaded
guerler
parents:
diff changeset
14
001c5e3e5517 Uploaded
guerler
parents:
diff changeset
15 # collect vectors in list
001c5e3e5517 Uploaded
guerler
parents:
diff changeset
16 l <- append(l, list(hist_data$breaks[2: length(hist_data$breaks)]))
001c5e3e5517 Uploaded
guerler
parents:
diff changeset
17 l <- append(l, list(hist_data$density))
001c5e3e5517 Uploaded
guerler
parents:
diff changeset
18 }
001c5e3e5517 Uploaded
guerler
parents:
diff changeset
19
001c5e3e5517 Uploaded
guerler
parents:
diff changeset
20 # return
001c5e3e5517 Uploaded
guerler
parents:
diff changeset
21 return (l)
001c5e3e5517 Uploaded
guerler
parents:
diff changeset
22 }