Mercurial > repos > guerler > charts
changeset 5:cbdd329ab623 draft
Uploaded
author | guerler |
---|---|
date | Thu, 17 Apr 2014 12:45:29 -0400 |
parents | b079b17dcb4a |
children | 6a11aeb8bd39 |
files | histogram.r |
diffstat | 1 files changed, 5 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/histogram.r Thu Apr 17 11:19:54 2014 -0400 +++ b/histogram.r Thu Apr 17 12:45:29 2014 -0400 @@ -13,7 +13,10 @@ hist_data <- hist(column_data, plot=FALSE) # normalize densities - hist_data$counts=hist_data$counts/sum(hist_data$counts) + count_sum <- sum(hist_data$counts) + if (count_sum > 0) { + hist_data$counts=hist_data$counts/count_sum + } # collect vectors in list l <- append(l, list(hist_data$breaks[2: length(hist_data$breaks)])) @@ -23,7 +26,7 @@ # make sure length is fine n <- max(sapply(l, length)) ll <- lapply(l, function(X) { - c(as.character(X), rep("", times = n - length(X))) + c(as.character(X), rep('undefined', times = n - length(X))) }) l <- do.call(cbind, ll)