[R] Error: if statement: missing value where TRUE/FALSE needed
Chuck Coleman
chuckco|em@n @end|ng |rom y@hoo@com
Thu Jan 6 19:05:59 CET 2022
I added the sink() commands to capture the output I was seeing and saw no noticeable difference. Granted, I didn't look too hard. Still, the code ran for the usual time before the error. Remove the print() commands and you'll probably the error in an entirely different iteration.
Thanks for helping,
Chuck
On Thursday, January 6, 2022, 12:14:15 PM EST, Duncan Murdoch <murdoch.duncan using gmail.com> wrote:
I've downloaded your code, and I'm seeing some strange results. When I
source MetroTest.R, it creates a log file ending
Error in if (xseg[w1] > ub & m == 1) olrmark[wi] = TRUE else if
(xseg[w1] < :
missing value where TRUE/FALSE needed
as you saw. But when I comment out the sink() lines in it, I don't see
an error. If I comment out only the first sink line, i.e. run with
my_log <- file("MetroTest.log")
#sink(my_log, append = TRUE, type = "output") # Writing console
output to log file
sink(my_log, append = TRUE, type = "message")
I get an error on the last line:
> sink(my_log, append = TRUE, type = "message")
Error in sink(my_log, append = TRUE, type = "message") :
'file' must be NULL or an already open connection
Once running this code R crashed.
I find all of that quite perplexing. I suspect one of the packages has
some buggy code, but I don't know which one. Currently I'm running the
script after running gctorture(); that's really slow. If it turns up
anything I'll let you know.
Duncan Murdoch
On 06/01/2022 10:23 a.m., Chuck Coleman wrote:
> I've created a git repository at https://sourceforge.net/p/rhelp/code/ci/master/tree/. I've used git before, so that's what I chose. I had forgotten that sourceforge didn't have a download all files command. I don't post files often.
>
> About the semantics of "crash": Perhaps I'm showing my age here. It used to be that programs crashed, bombed, etc. when they hit unanticipated errors. These programs lived in a OS without an intermediary. Now, we have programs of programs running within multiple applications on multiple servers with multiple OSs. Since I'm not a programmer by profession, I've had little need to use these constructs.
>
> Chuck Coleman
>
>
>
> On Wednesday, January 5, 2022, 02:51:07 PM EST, Duncan Murdoch <murdoch.duncan using gmail.com> wrote:
>
>
>
>
>
> 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