Re: [R] source() vs attach()0

2009-11-11 Thread Stefan Zeugner
Duncan Murdoch wrote: Just declaring it there is the only reasonable way, i.e. test<-function(foo) { subtest <- function() { foo <<- foo+1 } subtest() return(foo) } The reason you can't somehow assign it within an existing test is that subtest is a different closure every time.

Re: [R] source() vs attach()0

2009-11-11 Thread Duncan Murdoch
On 11/11/2009 10:19 AM, Stefan Zeugner wrote: Duncan Murdoch wrote: Just declaring it there is the only reasonable way, i.e. test<-function(foo) { subtest <- function() { foo <<- foo+1 } subtest() return(foo) } The reason you can't somehow assign it within an existing test is that

Re: [R] source() vs attach()0

2009-11-10 Thread Duncan Murdoch
On 11/10/2009 11:14 AM, Stefan Zeugner wrote: Hello, After hours of googling I could not resolve the following (although it seems simple): I would like to put subfunctions in a separate .R file that is then called with source() from inside several "main" functions. A crude example would be a

[R] source() vs attach()0

2009-11-10 Thread Stefan Zeugner
Hello, After hours of googling I could not resolve the following (although it seems simple): I would like to put subfunctions in a separate .R file that is then called with source() from inside several "main" functions. A crude example would be as follows: file subtest.R ** sub