Ivan Krylov
2022-Jan-05 18:22 UTC
[R] Error: if statement: missing value where TRUE/FALSE needed
On Wed, 5 Jan 2022 15:47:07 +0000 (UTC) Chuck Coleman via R-help <r-help at r-project.org> wrote:> I then made the browser() statement conditional to stop execution if > a missing argument were encountered and detectspikes() happily passed > it and crashed.How exactly do you check for a missing argument? Could options(error = recover) shed some more light on the situation? This way a crash happens first, then you get to use browser() to take a look at the environment at the time of the crash. -- Best regards, Ivan
Ivan Krylov
2022-Jan-05 19:09 UTC
[R] Error: if statement: missing value where TRUE/FALSE needed
On Wed, 5 Jan 2022 21:22:37 +0300 Ivan Krylov <krylov.r00t at gmail.com> wrote:> How exactly do you check for a missing argument?To answer my own question, the check is>> browser(expr = { >> is.na(w1) | is.na(ub) | is.na(m) | is.na(wi) | is.na(lb) >> })I think that there are NAs in xseg, which I don't see a check for. In particular, a few lines above, there's>> md = median( xseg, na.rm = TRUE); >> if (robust) sdd = mad(xseg,na.rm = TRUE) >> else sdd = sd(xseg,na.rm = TRUE)...which seems to suggest they are expected to happen there. Not sure which advice to give regarding the choice of file hosting service. On the one hand, SourceForge lets you upload a whole directory of files in arbitrary formats, but isn't very convenient do download more than one file from. On the other hand, "pastebin" services like http://paste.debian.net/ or http://paste.org.ru/ let us browse the code right away, without having to look at the "Your download will start shortly..." screen, but don't host *.RData or more than one file per link. I guess that some other code hosting service like SourceHut/GitHub/GitLab/Gitea/... could fulfil both criteria. -- Best regards, Ivan