Re: [R] Error Awareness

2021-12-26 Thread David Winsemius



On 12/23/21 3:11 AM, Stephen H. Dawson, DSL via R-help wrote:

Hi,


I am thinking about awareness of errors when an R script runs.

My concern is I have an error-free script. I run it for months on end 
without problems. Then, something changes somewhere causing an error. 
My wonderment is how R will tell me I had an error in the script, but 
the rest of the script ran without impairment.


QUESTIONS
What are some of the more helpful options available to an R developer 
to capture errors in a script run?


What are some of the best processes to implement these more helpful 
options?


See this insight from Spencer Graves from Feb 2011 on Rhelp:

https://stat.ethz.ch/pipermail/r-help/2011-February/268512.html





Thanks,


__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Error Awareness

2021-12-24 Thread Richard O'Keefe
You want to read this:

http://adv-r.had.co.nz/Exceptions-Debugging.html

It describes all the ways that R can report a problem
and all the ways you can catch such a report while still in R.

Let me heartily recommend the whole site, or better yet, the book
https://www.amazon.com/dp/0815384572/ref=cm_sw_su_dp?tag=devtools-20



On Fri, 24 Dec 2021 at 00:14, Stephen H. Dawson, DSL via R-help <
r-help@r-project.org> wrote:

> Hi,
>
>
> I am thinking about awareness of errors when an R script runs.
>
> My concern is I have an error-free script. I run it for months on end
> without problems. Then, something changes somewhere causing an error. My
> wonderment is how R will tell me I had an error in the script, but the
> rest of the script ran without impairment.
>
> QUESTIONS
> What are some of the more helpful options available to an R developer to
> capture errors in a script run?
>
> What are some of the best processes to implement these more helpful
> options?
>
>
> Thanks,
> --
> *Stephen Dawson, DSL*
> /Executive Strategy Consultant/
> Business & Technology
> +1 (865) 804-3454
> http://www.shdawson.com 
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Error Awareness

2021-12-24 Thread Avi Gross via R-help
Stephen,

I actually happen to like debates and abstractions especially covering multiple 
languages and domains but not HERE. As you note, some people created this forum 
for several purposes but the word HELP should provide a clue as to the main 
purpose. It is not meant to teach R or do homework for people but is somewhere 
in between and elsewhere. Ideally, it helps people who are a bit stuck 
somewhere but can already program and need a fresh pair of eyes or some domain 
knowledge to get over that problem and continue. The Posting Guide spells it 
out.

There is some latitude but stretching it too far can be a problem. Plenty of 
people do and I suppose some of my longer messages also make me guilty. And 
people who repeatedly ask for one thing after another, often are those who 
should do some independent study before working on the problems as the people 
who volunteer here generally do not want a full-time unpaid tutoring job.

If you can find another forum that welcomes lively debates on what is good or 
bad about a language like R or discusses alternative ways to do things or bet 
practices and so on, or what new features might be helpful, let me know and I 
might join.

For now, I think I will step aside and focus my efforts elsewhere.

-Original Message-
From: Stephen H. Dawson, DSL  
Sent: Friday, December 24, 2021 9:49 AM
To: Avi Gross ; 'r-help mailing list' 

Subject: Re: [R] Error Awareness

Thank you, Avi. I appreciate your reply. I agree maturing code is the best move 
to answer this interrogatory. I express deep thanks for contextualizing your 
response.

I also agree with you responses are becoming a pattern here. A post of an 
open-ended question regarding either a conceptual or stylistic topic is 
answered pervasively with linear thinking. This combination is a mismatch of 
context.

https://www.r-project.org/posting-guide.html

I summarize reading in the R Posting Guide, which is written in English, the 
recommendation to state a specific question involving specific R functionality. 
I read nothing in the R Posting Guide where open-ended questions are disallowed 
or even discouraged. Furthermore, I cannot imagine not posting either 
conceptual or stylistic questions to any practice group. If learning is not 
accomplished by open-ended questions, then there is nothing left other than 
closed-ended (direct) questions.

All the same, the benefit of gaining either tacit understanding or wisdom to 
use the R language by way of open-ended questioning is not found in the R 
Posting Guide as it is either written or practiced. This reality impairs the 
ability to learn about a dialogue member's thought process. It also impairs the 
ability to ever be able to one day offer either contract or employment work to 
anyone demonstrating both intimate knowledge of the R language and having the 
wisdom to implement it effectively.

It is inappropriate to recommend modifications to the R Posting Guide in this 
discussion, as it would be out of scope. So, I will not do it.

I close this dialogue as resolved. It is best to post any further discussion of 
this interrogatory in a new dialogue to avoid violating the R Posting Guide 
requirement of the stated Latin term ad hominem.

  https://www.dictionary.com/browse/ad-hominem

  https://en.wikipedia.org/wiki/Ad_hominem#Terminology


  Kindest Regards,
*Stephen Dawson, DSL*
/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.com <http://www.shdawson.com>


On 12/23/21 10:28 PM, Avi Gross via R-help wrote:
> Stephen,
>
> It is becoming a pattern here.
>
> You have been told R allows ways to check for errors as the code is 
> interpreted and this DOES NOT distinguish between development aspects 
> and in the field. It does not matter if a problem is external like a 
> required file not being in place or having a new name or whatever.
>
> Anything that may go wrong can be handled in quite a few ways. Some 
> are fairly obvious, such as checking if an expected  list or vector or 
> whatever is returned that is empty or not set or is the wrong data 
> type or contains some NA or negative numbers and on and on. All kinds 
> of IF statements and checks are a way to deal with these and you 
> decide whether to make some kind of fix or abort.
>
> But obviously if the error happens outside your code (and sometimes 
> also
> within) you can use various ways R provides to intercept the error and 
> do something. Heck, people often use this in advance as a programming 
> tactic such as using try() or tryCatch() to something like try to open 
> file1 in the current directory and if that fails, in a specified 
> directory and maybe if that fails, get it from file2 or maybe standard input 
> ...
>
> Well-written code that wants to be bullet-proof will often be a bit 
> bloated as it regularly stops and checks not only for all ki

Re: [R] Error Awareness

2021-12-24 Thread Stephen H. Dawson, DSL via R-help
Thank you, Avi. I appreciate your reply. I agree maturing code is the 
best move to answer this interrogatory. I express deep thanks for 
contextualizing your response.


I also agree with you responses are becoming a pattern here. A post of 
an open-ended question regarding either a conceptual or stylistic topic 
is answered pervasively with linear thinking. This combination is a 
mismatch of context.


https://www.r-project.org/posting-guide.html

I summarize reading in the R Posting Guide, which is written in English, 
the recommendation to state a specific question involving specific R 
functionality. I read nothing in the R Posting Guide where open-ended 
questions are disallowed or even discouraged. Furthermore, I cannot 
imagine not posting either conceptual or stylistic questions to any 
practice group. If learning is not accomplished by open-ended questions, 
then there is nothing left other than closed-ended (direct) questions.


All the same, the benefit of gaining either tacit understanding or 
wisdom to use the R language by way of open-ended questioning is not 
found in the R Posting Guide as it is either written or practiced. This 
reality impairs the ability to learn about a dialogue member's thought 
process. It also impairs the ability to ever be able to one day offer 
either contract or employment work to anyone demonstrating both intimate 
knowledge of the R language and having the wisdom to implement it 
effectively.


It is inappropriate to recommend modifications to the R Posting Guide in 
this discussion, as it would be out of scope. So, I will not do it.


I close this dialogue as resolved. It is best to post any further 
discussion of this interrogatory in a new dialogue to avoid violating 
the R Posting Guide requirement of the stated Latin term ad hominem.


 https://www.dictionary.com/browse/ad-hominem

 https://en.wikipedia.org/wiki/Ad_hominem#Terminology


 Kindest Regards,
*Stephen Dawson, DSL*
/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.com <http://www.shdawson.com>


On 12/23/21 10:28 PM, Avi Gross via R-help wrote:

Stephen,

It is becoming a pattern here.

You have been told R allows ways to check for errors as the code is
interpreted and this DOES NOT distinguish between development aspects and in
the field. It does not matter if a problem is external like a required file
not being in place or having a new name or whatever.

Anything that may go wrong can be handled in quite a few ways. Some are
fairly obvious, such as checking if an expected  list or vector or whatever
is returned that is empty or not set or is the wrong data type or contains
some NA or negative numbers and on and on. All kinds of IF statements and
checks are a way to deal with these and you decide whether to make some kind
of fix or abort.

But obviously if the error happens outside your code (and sometimes also
within) you can use various ways R provides to intercept the error and do
something. Heck, people often use this in advance as a programming tactic
such as using try() or tryCatch() to something like try to open file1 in the
current directory and if that fails, in a specified directory and maybe if
that fails, get it from file2 or maybe standard input ...

Well-written code that wants to be bullet-proof will often be a bit bloated
as it regularly stops and checks not only for all kinds of error conditions
but also checks if the variables being used are in the proper format and
range before being passed to functions that might break, is say you told it
to use a correlation above 1. It also decides to intelligently deal with the
errors, when possible.

I have written code that called a statistical analysis (lavaan)  function
hundreds of thousands of times on randomly generated data and it worked
fine, except occasionally it broke. As I tended to run it overnight, it was
a pain to wake up and find it had crashed. No, I am not aware why it
crashed, but it could have been something as simple as a matrix that could
not be inverted. But for my purposes, it did not matter as what I would be
happy to get is knowing it failed, marking associated rows of a data.frame
accordingly, and filtering out the results in later analyses. So, I wrapped
not only this call but some others as described above and intercepted the
rare problem and dealt with it and let my program continue overnight.

Clearly if you expect anomalies to be rare, this is extra overhead. But if
things do happen, then your code is not robust enough.

-Original Message-
From: R-help  On Behalf Of Stephen H. Dawson,
DSL via R-help
Sent: Thursday, December 23, 2021 11:17 AM
To: Bert Gunter 
Cc: R-help 
Subject: Re: [R] Error Awareness

Hi Bert,


Thanks for the reply.

The use case I presented involves working code, not diagnosing a script in
development.

The concern is running a script where something changes outside of the
script, as I stated. An example of a change is a d

Re: [R] Error Awareness

2021-12-23 Thread Avi Gross via R-help
Stephen,

It is becoming a pattern here.

You have been told R allows ways to check for errors as the code is
interpreted and this DOES NOT distinguish between development aspects and in
the field. It does not matter if a problem is external like a required file
not being in place or having a new name or whatever.

Anything that may go wrong can be handled in quite a few ways. Some are
fairly obvious, such as checking if an expected  list or vector or whatever
is returned that is empty or not set or is the wrong data type or contains
some NA or negative numbers and on and on. All kinds of IF statements and
checks are a way to deal with these and you decide whether to make some kind
of fix or abort.

But obviously if the error happens outside your code (and sometimes also
within) you can use various ways R provides to intercept the error and do
something. Heck, people often use this in advance as a programming tactic
such as using try() or tryCatch() to something like try to open file1 in the
current directory and if that fails, in a specified directory and maybe if
that fails, get it from file2 or maybe standard input ...

Well-written code that wants to be bullet-proof will often be a bit bloated
as it regularly stops and checks not only for all kinds of error conditions
but also checks if the variables being used are in the proper format and
range before being passed to functions that might break, is say you told it
to use a correlation above 1. It also decides to intelligently deal with the
errors, when possible.

I have written code that called a statistical analysis (lavaan)  function
hundreds of thousands of times on randomly generated data and it worked
fine, except occasionally it broke. As I tended to run it overnight, it was
a pain to wake up and find it had crashed. No, I am not aware why it
crashed, but it could have been something as simple as a matrix that could
not be inverted. But for my purposes, it did not matter as what I would be
happy to get is knowing it failed, marking associated rows of a data.frame
accordingly, and filtering out the results in later analyses. So, I wrapped
not only this call but some others as described above and intercepted the
rare problem and dealt with it and let my program continue overnight.

Clearly if you expect anomalies to be rare, this is extra overhead. But if
things do happen, then your code is not robust enough.

-Original Message-
From: R-help  On Behalf Of Stephen H. Dawson,
DSL via R-help
Sent: Thursday, December 23, 2021 11:17 AM
To: Bert Gunter 
Cc: R-help 
Subject: Re: [R] Error Awareness

Hi Bert,


Thanks for the reply.

The use case I presented involves working code, not diagnosing a script in
development.

The concern is running a script where something changes outside of the
script, as I stated. An example of a change is a data source changing
perhaps the columns in the data source, or even changing the spelling of a
column. The point is something changes.

The question then becomes how to be aware of the change when the reset of
the script runs fine, as I presented.

Think of having a script running daily where you are not running it
manually. How do you know there are errors in the script processing at this
point?

Does this question now make more sense?


*Stephen Dawson, DSL*
/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.com <http://www.shdawson.com>


On 12/23/21 10:49 AM, Bert Gunter wrote:
> ?tryCatch
>
> This list is not meant for tutorials. A web search on "find errors in 
> R code" brought up what appeared to be many resources to address your 
> question. Please make use of such resources before posting here. Also, 
> please read and follow the posting gui)de linked below to find out 
> what sort of help you can expect (and have already received here.
>
> Cheers,
> Bert Gunter
>
> "The trouble with having an open mind is that people keep coming along 
> and sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
> On Thu, Dec 23, 2021 at 3:14 AM Stephen H. Dawson, DSL via R-help 
>  wrote:
>> Hi,
>>
>>
>> I am thinking about awareness of errors when an R script runs.
>>
>> My concern is I have an error-free script. I run it for months on end 
>> without problems. Then, something changes somewhere causing an error. 
>> My wonderment is how R will tell me I had an error in the script, but 
>> the rest of the script ran without impairment.
>>
>> QUESTIONS
>> What are some of the more helpful options available to an R developer 
>> to capture errors in a script run?
>>
>> What are some of the best processes to implement these more helpful
options?
>>
>>
>> Thanks,
>> --
>> *Stephen Dawson, DSL*
>> /Executive Strategy Consultant

Re: [R] Error Awareness

2021-12-23 Thread Jeff Newmiller
You still are not exhibiting signs of understanding Bert's response, and your 
question is vague, particularly to the extent that it could be pertinent to the 
R language (and therefore to the topic of this list). R itself just raises an 
error condition that custom tryCatch or default handling will deal with. If you 
run the script in a logging context (as defined by a non-R, 
operating-system-specific tool) then whatever error was printed by R to stdout 
or stderr will be in that log. If you want some different form communication 
then you will need to use tryCatch and initiate that effort. But since R itself 
doesn't know how you are running it (cron? CGI? Windows Task Manager? 
self-implemented socket monitoring?) it is up to you to deal with that.

If you have a more focused question (e.g. how can I send an email or text) then 
there may well be a package for that, but you can find such things yourself 
with a search engine and discussion of how to use them is almost certainly 
off-topic here (read the Posting Guide).

On December 23, 2021 8:16:58 AM PST, "Stephen H. Dawson, DSL via R-help" 
 wrote:
>Hi Bert,
>
>
>Thanks for the reply.
>
>The use case I presented involves working code, not diagnosing a script 
>in development.
>
>The concern is running a script where something changes outside of the 
>script, as I stated. An example of a change is a data source changing 
>perhaps the columns in the data source, or even changing the spelling of 
>a column. The point is something changes.
>
>The question then becomes how to be aware of the change when the reset 
>of the script runs fine, as I presented.
>
>Think of having a script running daily where you are not running it 
>manually. How do you know there are errors in the script processing at 
>this point?
>
>Does this question now make more sense?
>
>
>*Stephen Dawson, DSL*
>/Executive Strategy Consultant/
>Business & Technology
>+1 (865) 804-3454
>http://www.shdawson.com 
>
>
>On 12/23/21 10:49 AM, Bert Gunter wrote:
>> ?tryCatch
>>
>> This list is not meant for tutorials. A web search on "find errors in
>> R code" brought up what appeared to be many resources to address your
>> question. Please make use of such resources before posting here. Also,
>> please read and follow the posting gui)de linked below to find out
>> what sort of help you can expect (and have already received here.
>>
>> Cheers,
>> Bert Gunter
>>
>> "The trouble with having an open mind is that people keep coming along
>> and sticking things into it."
>> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>>
>> On Thu, Dec 23, 2021 at 3:14 AM Stephen H. Dawson, DSL via R-help
>>  wrote:
>>> Hi,
>>>
>>>
>>> I am thinking about awareness of errors when an R script runs.
>>>
>>> My concern is I have an error-free script. I run it for months on end
>>> without problems. Then, something changes somewhere causing an error. My
>>> wonderment is how R will tell me I had an error in the script, but the
>>> rest of the script ran without impairment.
>>>
>>> QUESTIONS
>>> What are some of the more helpful options available to an R developer to
>>> capture errors in a script run?
>>>
>>> What are some of the best processes to implement these more helpful options?
>>>
>>>
>>> Thanks,
>>> --
>>> *Stephen Dawson, DSL*
>>> /Executive Strategy Consultant/
>>> Business & Technology
>>> +1 (865) 804-3454
>>> http://www.shdawson.com 
>>>
>>> __
>>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>
>__
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

-- 
Sent from my phone. Please excuse my brevity.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Error Awareness

2021-12-23 Thread Stephen H. Dawson, DSL via R-help

Hi Bert,


Thanks for the reply.

The use case I presented involves working code, not diagnosing a script 
in development.


The concern is running a script where something changes outside of the 
script, as I stated. An example of a change is a data source changing 
perhaps the columns in the data source, or even changing the spelling of 
a column. The point is something changes.


The question then becomes how to be aware of the change when the reset 
of the script runs fine, as I presented.


Think of having a script running daily where you are not running it 
manually. How do you know there are errors in the script processing at 
this point?


Does this question now make more sense?


*Stephen Dawson, DSL*
/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.com 


On 12/23/21 10:49 AM, Bert Gunter wrote:

?tryCatch

This list is not meant for tutorials. A web search on "find errors in
R code" brought up what appeared to be many resources to address your
question. Please make use of such resources before posting here. Also,
please read and follow the posting gui)de linked below to find out
what sort of help you can expect (and have already received here.

Cheers,
Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Thu, Dec 23, 2021 at 3:14 AM Stephen H. Dawson, DSL via R-help
 wrote:

Hi,


I am thinking about awareness of errors when an R script runs.

My concern is I have an error-free script. I run it for months on end
without problems. Then, something changes somewhere causing an error. My
wonderment is how R will tell me I had an error in the script, but the
rest of the script ran without impairment.

QUESTIONS
What are some of the more helpful options available to an R developer to
capture errors in a script run?

What are some of the best processes to implement these more helpful options?


Thanks,
--
*Stephen Dawson, DSL*
/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.com 

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Error Awareness

2021-12-23 Thread Bert Gunter
?tryCatch

This list is not meant for tutorials. A web search on "find errors in
R code" brought up what appeared to be many resources to address your
question. Please make use of such resources before posting here. Also,
please read and follow the posting gui)de linked below to find out
what sort of help you can expect (and have already received here.

Cheers,
Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Thu, Dec 23, 2021 at 3:14 AM Stephen H. Dawson, DSL via R-help
 wrote:
>
> Hi,
>
>
> I am thinking about awareness of errors when an R script runs.
>
> My concern is I have an error-free script. I run it for months on end
> without problems. Then, something changes somewhere causing an error. My
> wonderment is how R will tell me I had an error in the script, but the
> rest of the script ran without impairment.
>
> QUESTIONS
> What are some of the more helpful options available to an R developer to
> capture errors in a script run?
>
> What are some of the best processes to implement these more helpful options?
>
>
> Thanks,
> --
> *Stephen Dawson, DSL*
> /Executive Strategy Consultant/
> Business & Technology
> +1 (865) 804-3454
> http://www.shdawson.com 
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Error Awareness

2021-12-23 Thread Stephen H. Dawson, DSL via R-help

Hi,


I am thinking about awareness of errors when an R script runs.

My concern is I have an error-free script. I run it for months on end 
without problems. Then, something changes somewhere causing an error. My 
wonderment is how R will tell me I had an error in the script, but the 
rest of the script ran without impairment.


QUESTIONS
What are some of the more helpful options available to an R developer to 
capture errors in a script run?


What are some of the best processes to implement these more helpful options?


Thanks,
--
*Stephen Dawson, DSL*
/Executive Strategy Consultant/
Business & Technology
+1 (865) 804-3454
http://www.shdawson.com 

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.