IDEMSInternational / R-Instat

A statistics software package powered by R
http://r-instat.org/
GNU General Public License v3.0
38 stars 103 forks source link

Errors in length > 1 #9238

Open lilyclements opened 1 week ago

lilyclements commented 1 week ago

@rdstern @N-thony @MeSophie @Vitalis95 @derekagorhom We have finally moved to a more recent version of R, but, this means there are some things to flag. In R >=4.2.0 is.na() returns an error not a warning if x has more than one element.

So, the following used to throw a warning that they're only looking at if "A" is NA, but now it throws an error.

if (is.na(c("A", "B"))){
  print("hi")
}

I know of a couple of packages where this has caused problems in the past, but have since been updated to fix this. However, I do not know if our packages are updated to those more recent versions. I also do not know if we will have issues in our code over this.

If anyone sees an error that says the condition has length > 1, then please flag it here so I can go through and check and fix it / suggest the package to update to.

Thanks.

Patowhiz commented 1 week ago

I found one in another R function and made a similar request in comment in issue #9207.

I did a quick code check on the data_object_R6.R file, but didn't found another area that could potentially throw this kind of error. Would be good if someone could exhaustively examine the R base code because of the recent R upgrades.

Tagging @jkmusyoka as well just in case you get such an error during trainings.

lilyclements commented 1 week ago

@Patowhiz thanks, I'll look into this now

lilyclements commented 1 week ago

@Patowhiz I see you have already fixed it and explained the issue a lot better than I could have! Nice one. Thanks!