From 1de8185465002a770a1a4a1d837a79578e7f5618 Mon Sep 17 00:00:00 2001 From: atusy <30277794+atusy@users.noreply.github.com> Date: Wed, 21 Nov 2018 19:10:53 +0900 Subject: [PATCH] fix: if statement The code try to see if number of TRUE are same among each component of a list `matched`. However, if every component is composed only of FALSE, number of TRUE are 0 in all case. Resulting in `if(TRUE)` where `if(FALSE)` is intended. --- R/read_qnt_elemw.R | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/R/read_qnt_elemw.R b/R/read_qnt_elemw.R index 31d5f57..00b2d71 100644 --- a/R/read_qnt_elemw.R +++ b/R/read_qnt_elemw.R @@ -46,7 +46,10 @@ read_qnt_elemw.0_cnd <- function( # match pattern and return values matched <- lapply(pattern, function(pattern) str_detect(x, pattern)) - if(length(unique(lapply(matched, sum))) == 1) return( + if( + any(unlist(matched, use.names = FALSE)) && + length(unique(lapply(matched, sum))) == 1 + ) return( as.data.frame(lapply(matched, function(i) as.numeric(val[i]))) )