Re: [R] environments: functions within functions

2023-05-26 Thread Sarah Goslee
Very nice, thank you! Sarah On Thu, May 25, 2023 at 8:20 PM Iris Simmons wrote: > > Hi, > > > I think there are two easy ways to fix this. The first is to use a `switch` > to call the intended function, this should not be a problem since there are a > small number of print functions in **mixR

Re: [R] environments: functions within functions

2023-05-26 Thread Duncan Murdoch
I agree with Iris: the switch() solution looks like the best option here. The only change I'd make is to pass the dots down to the print function (or possibly warn about using them if those functions don't support any other parameters). Duncan Murdoch On 25/05/2023 8:20 p.m., Iris Simmons w

Re: [R] environments: functions within functions

2023-05-26 Thread Iris Simmons
Hi, I think there are two easy ways to fix this. The first is to use a `switch` to call the intended function, this should not be a problem since there are a small number of print functions in **mixR** ```R print.mixfitEM <- function (x, digits = getOption("digits"), ...) { switch(x$family,

Re: [R] environments: functions within functions

2023-05-25 Thread Sarah Goslee
Thank you to both Duncan and Ivan for the detailed answers. I'll point the mixR maintainer at this thread in the list archive, because your suggestions were so clear, and I can't explain them as thoroughly. I'll keep using x as the argument name for now. Much appreciated, Sarah On Thu, May 25, 2

Re: [R] environments: functions within functions

2023-05-25 Thread Ivan Krylov
(Sorry for the double post.) В Thu, 25 May 2023 18:53:45 +0300 Ivan Krylov пишет: > print(fit1) # tracer not called Interesting. There must be some caching involved. If print(a) is resolved to print.mixfitEM at least once, it keeps failing. In a fresh R session, where a trace()-patch is done be

Re: [R] environments: functions within functions

2023-05-25 Thread Ivan Krylov
В Thu, 25 May 2023 10:18:13 -0400 Sarah Goslee пишет: > print called on this object gets passed to print.mixfitEM(), which is: > > > function (x, digits = getOption("digits"), ...) > { > family <- x$family > mc <- match.call() > mc$digits <- digits > fun.name <- paste0("print",

Re: [R] environments: functions within functions

2023-05-25 Thread Duncan Murdoch
On 25/05/2023 10:18 a.m., Sarah Goslee wrote: Hi, I ran into a problem with S3 method dispatch and scoping while trying to use functions from the mixR package within my own functions. I know enough to find the problem (I think!), but not enough to fix it myself. The problem isn't really a packag

[R] environments: functions within functions

2023-05-25 Thread Sarah Goslee
Hi, I ran into a problem with S3 method dispatch and scoping while trying to use functions from the mixR package within my own functions. I know enough to find the problem (I think!), but not enough to fix it myself. The problem isn't really a package-specific problem, so I'm starting here, and wi