Mercurial > repos > iuc > charts
view histogramdiscrete.r @ 0:a87a3773d8ed draft
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/charts/ commit 87080d49913cfd40a77eda7e5834ac9c4bc30b0b
author | iuc |
---|---|
date | Fri, 09 Mar 2018 08:23:08 -0500 |
parents | |
children | 344ac3ca7557 |
line wrap: on
line source
# wrapper wrapper <- function(table, columns, options) { # initialize output list l <- list() # loop through all columns m <- list() for (key in names(columns)) { # load column data column <- as.numeric(columns[key]) # ensure string column column_data <- as.character(table[column][[1]]) # collect vectors in list m <- append(m, list(column_data)) } # get alphabetically sorted bins bins <- sort(unique(unlist(m))) # add first column l <- append(l, list(bins)) # loop through all columns for (key in seq(m)) { # reset bins bins = sapply(bins, function(v) { 0 }) # load column data column_data <- m[[key]] # create hist data table_data <- table(column_data) # transfer counts to bins for (id in names(table_data)) { bins[id] <- table_data[id] } # normalize densities total <- length(column_data) if (total > 0) { bins = bins / total } # collect vectors in list l <- append(l, list(bins)) } # return return (l) }