Created
November 6, 2018 16:25
-
-
Save Martin-Jung/38529d4f314fb6588046a5ff354018fd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define function to calculate area between the curves | |
area.between.curves <- function(yAxis1, yAxis2, xAxis) | |
{ | |
d <- c(yAxis2 - yAxis1)[-1] | |
d <- d * diff(xAxis) | |
neg <- sum(abs(d[which(d < 0)])) | |
pos <- sum(d[which(d > 0)]) | |
abc <- list() | |
if(neg > pos) abc[[1]] <- neg*-1 | |
if(pos > neg) abc[[1]] <- pos | |
abc[[2]] <- c(pos, neg)/(pos+abs(neg)) | |
return(abc) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment