Re: [R] Display warning only once in session

2014-08-25 Thread Grant Rettke
Is local preferred to prevent *any* access to the internal environment of the returned function? How is it different than this? myFunc <- function() { notWarnedYet <- TRUE function(x) { if (notWarnedYet) { warning("myFunc is funky") notWarnedYet <<- FALSE #

Re: [R] Display warning only once in session

2014-08-25 Thread William Dunlap
> Is local preferred to prevent *any* access to the internal environment > of the returned function? You can gain access to the environment of the function by using environment(myFunc), with either local() or your suggestion of making a factory function and calling it. > How is it different than

Re: [R] Display warning only once in session

2014-08-25 Thread William Dunlap
You could use local() to associate a state variable with your function: myFunc <- local({ notWarnedYet <- TRUE function(x) { if (notWarnedYet) { warning("myFunc is funky") notWarnedYet <<- FALSE # note use of <<- } sqrt

[R] Display warning only once in session

2014-08-25 Thread Berry Boessenkool
Hi, I'm writing a function that gives a warning in a certain scenario. Reading this once per R session will be enough. i.e. it's not necessary to be shown in subsequent function calls. What's the best way to implement this? Some package-specific option? Where would I find good information on tha