aboutsummaryrefslogtreecommitdiff
path: root/KOR.addrlink/R/l1score.R
diff options
context:
space:
mode:
Diffstat (limited to 'KOR.addrlink/R/l1score.R')
-rw-r--r--KOR.addrlink/R/l1score.R8
1 files changed, 8 insertions, 0 deletions
diff --git a/KOR.addrlink/R/l1score.R b/KOR.addrlink/R/l1score.R
new file mode 100644
index 0000000..86154ed
--- /dev/null
+++ b/KOR.addrlink/R/l1score.R
@@ -0,0 +1,8 @@
+l1score <-
+function(x){
+ stopifnot(is.vector(x) & is.numeric(x))
+ if(sum(is.na(x)) == length(x)){return(rep(1, length(x)))}
+ stopifnot(is.numeric(x))
+ x <- abs(x)
+ 1 - x / max(c(1, x), na.rm = TRUE)
+}