Skip to content

Commit

Permalink
fix: if statement
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
atusy committed Nov 21, 2018
1 parent f33711c commit 1de8185
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion R/read_qnt_elemw.R
Original file line number Diff line number Diff line change
Expand Up @@ -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])))
)

Expand Down

0 comments on commit 1de8185

Please sign in to comment.