PageRenderTime 61ms CodeModel.GetById 58ms app.highlight 0ms RepoModel.GetById 2ms app.codeStats 0ms

/pkg/R/brokenX.R

https://code.google.com/
R | 20 lines | 14 code | 1 blank | 5 comment | 6 complexity | 55b7d01a17f4f20e0e7ae74517b6bd79 MD5 | raw file
 1brokenX <- function(num, bias_brokenX) {
 2## bias_brokenX: parameter between 0 en 1 that determines when x-axis is broken
 3##               if minimum value is at least <bias_brokenX> times the maximum value, then X axis is broken
 4
 5	minmax <- range(num, na.rm=TRUE)
 6	if ((minmax[2]) > 0 && minmax[1] > (bias_brokenX * minmax[2])) {
 7		## broken x-axis has positive values
 8		brokenX <- 1
 9		values <- num - minmax[1]
10	} else if ((minmax[1]) < 0 && minmax[2] < (bias_brokenX * minmax[1])) {
11		## broken x-axis has negative values
12		brokenX <- -1
13		values <- num - minmax[2]
14	} else {
15		## x-axis not broken
16		brokenX <- 0
17		values <- num
18	}
19	return(list(brokenX=brokenX, values=values))
20}