Re: [Rd] how to control the environment of a formula

2013-04-20 Thread Thomas Alexander Gerds
thanks. yes, I was considering to use as.character(f) but your solution 2 is much better -- did not know ' was a R function as well. just checked: model.frame does not get confused and this will be used to evaluate formula by all functions in my packages. however, there could be related problems

Re: [Rd] how to control the environment of a formula

2013-04-20 Thread Gabor Grothendieck
On Sat, Apr 20, 2013 at 1:44 PM, Duncan Murdoch wrote: > On 13-04-19 2:57 PM, Thomas Alexander Gerds wrote: >> >> >> hmm. I have tested a bit more, and found this perhaps more difficult >> solve situation. even though I delete x, since x is part of the output >> of the formula, the size of the obj

Re: [Rd] how to control the environment of a formula

2013-04-20 Thread Duncan Murdoch
On 13-04-19 2:57 PM, Thomas Alexander Gerds wrote: hmm. I have tested a bit more, and found this perhaps more difficult solve situation. even though I delete x, since x is part of the output of the formula, the size of the object is twice as much as it should be: test <- function(x){ x <- rn

Re: [Rd] how to control the environment of a formula

2013-04-19 Thread Thomas Alexander Gerds
hmm. I have tested a bit more, and found this perhaps more difficult solve situation. even though I delete x, since x is part of the output of the formula, the size of the object is twice as much as it should be: test <- function(x){ x <- rnorm(100) out <- list(x=x) rm(x) out$f <- as.

Re: [Rd] how to control the environment of a formula

2013-04-19 Thread Therneau, Terry M., Ph.D.
Duncan, I stand by all my comments. Well behaved function -- those that look only at their input arguments -- do just fine with a simple env. Now as to formulas --- the part of R that has most aggressively messed with normal evaluation rules. It is quite possible that there is/was no other way

Re: [Rd] how to control the environment of a formula

2013-04-19 Thread Duncan Murdoch
On 13-04-19 8:41 AM, Therneau, Terry M., Ph.D. wrote: I went through the same problem and discovery process 2 years ago with the survival package. With pspline() terms the return object from coxph includes a simple 6 line function for enhanced printout, which by default carried along anoth

Re: [Rd] how to control the environment of a formula

2013-04-19 Thread Duncan Murdoch
On 13-04-18 11:39 AM, Thomas Alexander Gerds wrote: Dear Duncan thank you for taking the time to answer my questions! It will be quite some work to delete all the objects generated inside the function ... but if there is no other way to avoid a large environment then this is what I will do. It

Re: [Rd] how to control the environment of a formula

2013-04-19 Thread Therneau, Terry M., Ph.D.
I went through the same problem and discovery process 2 years ago with the survival package. With pspline() terms the return object from coxph includes a simple 6 line function for enhanced printout, which by default carried along another 30 irrelevant things some of which were huge. I person

Re: [Rd] how to control the environment of a formula

2013-04-18 Thread Thomas Alexander Gerds
Dear Duncan thank you for taking the time to answer my questions! It will be quite some work to delete all the objects generated inside the function ... but if there is no other way to avoid a large environment then this is what I will do. Cheers Thomas Duncan Murdoch writes: > On 13-04-18 1:

Re: [Rd] how to control the environment of a formula

2013-04-18 Thread Duncan Murdoch
On 13-04-18 1:09 AM, Thomas Alexander Gerds wrote: Dear List I have experienced that objects generated with one of my packages used a lot of space when saved on disc (object.size did not show this!). some debugging revealed that formula and call objects carried the full environment of subroutin

[Rd] how to control the environment of a formula

2013-04-18 Thread Thomas Alexander Gerds
Dear List I have experienced that objects generated with one of my packages used a lot of space when saved on disc (object.size did not show this!). some debugging revealed that formula and call objects carried the full environment of subroutines along, including even stuff not needed by the form