[R] Error: if statement: missing value where TRUE/FALSE needed

Duncan Murdoch murdoch@dunc@n @end|ng |rom gm@||@com
Wed Jan 5 20:51:05 CET 2022


On 05/01/2022 2:09 p.m., Ivan Krylov wrote:
> On Wed, 5 Jan 2022 21:22:37 +0300
> Ivan Krylov <krylov.r00t using 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.

I would take one step back, and suggest that if any project has as many 
scripts as this one, it should be put in an R package.  You can 
distribute that by building it into a tar.gz file and putting that 
single file in a place where people can download it.  Github and R-forge 
work well for packages, and I assume other hosting services do too, 
though I haven't used many.

People seem to be unreasonably reluctant to put their code into packages.

Duncan Murdoch



More information about the R-help mailing list