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

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

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,

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

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

[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

Re: [R] Reloading old R Environments/Workspaces

2019-07-04 Thread Spencer Brackett
Partly because the procedure itself is incomplete, but yes I see the illogic nature of my position. On Thu, Jul 4, 2019 at 4:22 PM Jeff Newmiller wrote: > If you can't reproduce them, how do you know they are correct? > > On July 4, 2019 11:34:53 AM PDT, Spencer Brackett < >

Re: [R] Reloading old R Environments/Workspaces

2019-07-04 Thread Jeff Newmiller
If you can't reproduce them, how do you know they are correct? On July 4, 2019 11:34:53 AM PDT, Spencer Brackett wrote: >Thank you for the clarification. So should I not rely on importing a >saved >environment from now on? I am currently experiencing some difficulties >with >reproducing the

Re: [R] Reloading old R Environments/Workspaces

2019-07-04 Thread Spencer Brackett
Thank you for the clarification. So should I not rely on importing a saved environment from now on? I am currently experiencing some difficulties with reproducing the output (aka the objects listed in my environment), which is why I was trying to load them all at once. Best, Spencer On Thu, Jul

Re: [R] Reloading old R Environments/Workspaces

2019-07-04 Thread Duncan Murdoch
On 04/07/2019 12:32 p.m., Spencer Brackett wrote: Hello again, I might be repeating myself here, so my apologies, but do I have to run a script file from my R Studio to reimplement my previous work for a given project so to start up where I left off or is opening up R and, with my

Re: [R] Reloading old R Environments/Workspaces

2019-07-04 Thread Spencer Brackett
Hello again, I might be repeating myself here, so my apologies, but do I have to run a script file from my R Studio to reimplement my previous work for a given project so to start up where I left off or is opening up R and, with my global environment automatically reloading as it was

Re: [R] Reloading old R Environments/Workspaces

2019-07-03 Thread Spencer Brackett
Very interesting I will have to take a look. Thank you very much for the reference to these resources! They will be of great help to me. Many thanks, Spencer On Wed, Jul 3, 2019 at 8:41 PM Jeff Newmiller wrote: > An R file is nothing more than a text file with an R extension instead of >

Re: [R] Reloading old R Environments/Workspaces

2019-07-03 Thread Jeff Newmiller
An R file is nothing more than a text file with an R extension instead of a TXT extension. Use any text editor you like to rearrange your commands in the order you want and remove false starts (beware of Notepad... it seems to have a tendency to tack on a .txt extension in addition to the .R

Re: [R] Reloading old R Environments/Workspaces

2019-07-03 Thread Spencer Brackett
I do have a script available, though it is not in a traditional R script file/document, but an .Rhistory file as well as on Notepad. Is there a way I can convert one or both of these file types into an R script file so that I can run the commands directly to my console? Best, Spencer On Wed,

Re: [R] Reloading old R Environments/Workspaces

2019-07-03 Thread Jeff Newmiller
Saving/loading does not affect the status of packages being loaded or not, which may affect how useful those objects are. This is why I depend on having a script that can reproduce my results at all times, and only use the load/save feature to minimize the number of times I have to re-do long

[R] Reloading old R Environments/Workspaces

2019-07-03 Thread Spencer Brackett
Good evening, I tried loading an R global environment that I had saved so to resume my work on the datasets I manipulated during that particular R session. After loading the file directly, the same items that were contained in the original working environment from the previous session appeared

[R] Environments

2009-04-02 Thread Philip Whittall
Dear List, No doubt I am going around this the wrong way, and hopefully one of you will be able to tell me how to go about it the right way. I want to change the names of an object inside a function and have it stay changed in the global environment. I can only effect the change inside the

Re: [R] Environments

2009-04-02 Thread Hans-Peter Suter
rename(x,C,Z) x - rename(x,C,Z) x A B Z D 1 2 3 4 -- Regards, Hans-Peter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide

Re: [R] Environments

2009-04-02 Thread Bill.Venables
] On Behalf Of Philip Whittall [philip.whitt...@detica.com] Sent: 02 April 2009 19:31 To: r-help@r-project.org Subject: [R] Environments Dear List, No doubt I am going around this the wrong way, and hopefully one of you will be able to tell me how to go about it the right way. I want to change

[R] environments

2008-08-26 Thread Antje
Hi there, I try to understand the usage of environments but I'm not sure if I get it. I wrote a test script like this: testenv - new.env(environment()) myfun - function(x) { print(testvar) testenv$testvar_2 - 20 } environment(myfun) - testenv testenv$testvar - 10

Re: [R] environments

2008-08-26 Thread Henrique Dallazuanna
I think you need assign, see ?assign for more details. On Tue, Aug 26, 2008 at 6:02 AM, Antje [EMAIL PROTECTED] wrote: Hi there, I try to understand the usage of environments but I'm not sure if I get it. I wrote a test script like this: testenv - new.env(environment()) myfun -

Re: [R] environments

2008-08-26 Thread Douglas Bates
On Tue, Aug 26, 2008 at 6:07 AM, Henrique Dallazuanna [EMAIL PROTECTED] wrote: I think you need assign, see ?assign for more details. On Tue, Aug 26, 2008 at 6:02 AM, Antje [EMAIL PROTECTED] wrote: Hi there, I try to understand the usage of environments but I'm not sure if I get it. I wrote

Re: [R] environments

2008-08-26 Thread Peter Dalgaard
Douglas Bates wrote: As Henrique said, the canonical way of assigning a value within an environment is the assign. A more obscure, but also more effective, approach is evalq which quotes an expression then evaluates it in the given environment. For example env - new.env() evalq({aa -

Re: [R] environments

2008-08-26 Thread Antje
Okay, I see, there is no really easy way (I was wondering whether I can set an environment as default for new created variables). Is there any difference if I call myenv$myvar - 10 or assign(myvar,10, env=myenv) ? Antje Douglas Bates schrieb: On Tue, Aug 26, 2008 at 6:07 AM, Henrique

Re: [R] environments

2008-08-26 Thread Peter Dalgaard
Antje wrote: Okay, I see, there is no really easy way (I was wondering whether I can set an environment as default for new created variables). Is there any difference if I call myenv$myvar - 10 or assign(myvar,10, env=myenv) ? No. And with(myenv, myvar - 10) is also the same. However, you

Re: [R] environments

2008-08-26 Thread Duncan Murdoch
On 8/26/2008 9:44 AM, Peter Dalgaard wrote: Antje wrote: Okay, I see, there is no really easy way (I was wondering whether I can set an environment as default for new created variables). Is there any difference if I call myenv$myvar - 10 or assign(myvar,10, env=myenv) ? No. And with(myenv,