From b0921032b987527d4ed2db6bd886e1dab5a541dd Mon Sep 17 00:00:00 2001 From: owen vallis Date: Wed, 15 Apr 2015 16:14:32 -0700 Subject: [PATCH] adding check for nan before testing if R(max anom) is greater then lam(critical value) in detect_anoms. Fix suggested in issue #36 --- R/detect_anoms.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/detect_anoms.R b/R/detect_anoms.R index 4dc4f34..a6bcc0b 100644 --- a/R/detect_anoms.R +++ b/R/detect_anoms.R @@ -104,7 +104,7 @@ detect_anoms <- function(data, k = 0.49, alpha = 0.05, num_obs_per_period = NULL t <- qt(p,(n-i-1L)) lam <- t*(n-i) / sqrt((n-i-1+t**2)*(n-i+1)) - if(R > lam) + if(!is.nan(R) && R > lam) num_anoms <- i }