Skip to content

Commit

Permalink
correcting for the behaviour of is.na in if statement
Browse files Browse the repository at this point in the history
  • Loading branch information
pittlerf committed Oct 3, 2019
1 parent 17c3058 commit 81db664
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions R/cf.R
Original file line number Diff line number Diff line change
Expand Up @@ -751,15 +751,15 @@ addStat.cf <- function(cf1, cf2,reverse1=FALSE, reverse2=FALSE) {
icf1_temp <- cf1$icf
if (reverse1 == TRUE){
apply(cf1_temp,2,rev)
if (!is.na(icf1_temp)){
if (sum(is.na(icf1_temp))==0){

This comment has been minimized.

Copy link
@kostrzewa

kostrzewa Oct 3, 2019

Member

a cf can contain NA, so this test will fail in legal cases...

why don't you test is.null like everywhere else where we test for the existence of the imaginary part?

This comment has been minimized.

Copy link
@martin-ueding

martin-ueding Oct 8, 2019

Contributor

Also sum(logical_vector) == 0 should be all(logical_vector) because it is clearer and faster.

apply(icf1_temp,2,rev)
}
}
cf2_temp <- cf2$cf
icf2_temp <- cf2$icf
if (reverse2 == TRUE){
apply(cf2_temp,2,rev)
if (!is.na(icf2_temp)){
if (sum(is.na(icf2_temp))==0){
apply(icf2_temp,2,rev)
}
}
Expand Down

0 comments on commit 81db664

Please sign in to comment.