Re: [R] variable scope

2012-08-29 Thread Sam Steingold
> * Duncan Murdoch [2012-08-29 10:30:10 -0400]: > > On 29/08/2012 12:50 AM, Sam Steingold wrote: >> > * Duncan Murdoch [2012-08-28 21:06:33 -0400]: >> > >> > On 12-08-28 5:55 PM, Sam Steingold wrote: >> >> >> >> my observation is that gc in R sucks. >> >> (it cannot release small objects). >> >>

Re: [R] variable scope

2012-08-29 Thread Duncan Murdoch
On 29/08/2012 12:50 AM, Sam Steingold wrote: > * Duncan Murdoch [2012-08-28 21:06:33 -0400]: > > On 12-08-28 5:55 PM, Sam Steingold wrote: >>> * R. Michael Weylandt [2012-08-28 13:45:35 -0500]: >>> always you shouldn't need manual garbage collection. >> >> my observation is that gc in R s

Re: [R] variable scope

2012-08-28 Thread Sam Steingold
> * Duncan Murdoch [2012-08-28 21:06:33 -0400]: > > On 12-08-28 5:55 PM, Sam Steingold wrote: >>> * R. Michael Weylandt [2012-08-28 13:45:35 >>> -0500]: >>> always you shouldn't need manual garbage collection. >> >> my observation is that gc in R sucks. >> (it cannot release small objects).

Re: [R] variable scope

2012-08-28 Thread Sam Steingold
> * Jeff Newmiller [2012-08-28 15:21:39 -0700]: > > Sam Steingold wrote: > >>> * R. Michael Weylandt [2012-08-28 >>13:45:35 -0500]: >>> always you shouldn't need manual garbage collection. >> >>my observation is that gc in R sucks. >>(it cannot release small objects). >>this is not specific

Re: [R] variable scope

2012-08-28 Thread Sam Steingold
> * R. Michael Weylandt [2012-08-28 17:30:06 > -0500]: > >> In my experience, the one point I've needed it was after freeing >> multiple very large objects when hitting memory limits. that's what I am doing. >> Rewriting that code to use functions rather than as one long >> imperative slog was

Re: [R] variable scope

2012-08-28 Thread Jeff Newmiller
--- Jeff NewmillerThe . . Go Live... DCN:Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Sola

Re: [R] variable scope

2012-08-28 Thread Duncan Murdoch
On 12-08-28 5:55 PM, Sam Steingold wrote: * R. Michael Weylandt [2012-08-28 13:45:35 -0500]: always you shouldn't need manual garbage collection. my observation is that gc in R sucks. (it cannot release small objects). this is not specific to R; ocaml suffers too. Sorry, I didn't realize y

Re: [R] variable scope

2012-08-28 Thread R. Michael Weylandt
On Tue, Aug 28, 2012 at 5:13 PM, R. Michael Weylandt wrote: > On Tue, Aug 28, 2012 at 4:55 PM, Sam Steingold wrote: >>> * R. Michael Weylandt [2012-08-28 13:45:35 >>> -0500]: >>> always you shouldn't need manual garbage collection. >> >> my observation is that gc in R sucks. >> (it cannot

Re: [R] variable scope

2012-08-28 Thread R. Michael Weylandt
On Tue, Aug 28, 2012 at 4:55 PM, Sam Steingold wrote: >> * R. Michael Weylandt [2012-08-28 13:45:35 >> -0500]: >> >>> always you shouldn't need manual garbage collection. > > my observation is that gc in R sucks. > (it cannot release small objects). > this is not specific to R; ocaml suffers too

Re: [R] variable scope

2012-08-28 Thread Sam Steingold
> * R. Michael Weylandt [2012-08-28 13:45:35 > -0500]: > >> always you shouldn't need manual garbage collection. my observation is that gc in R sucks. (it cannot release small objects). this is not specific to R; ocaml suffers too. > since a loop doesn't define its own scope like some languages

Re: [R] variable scope

2012-08-28 Thread Duncan Murdoch
On 28/08/2012 2:29 PM, Sam Steingold wrote: At the end of a for loop its variables are still present: for (i in 1:10) { x <- vector(length=1) } ls() will print "i" and "x". this means that at the end of the for loop body I have to write rm(x) gc() is there a more elegant way

Re: [R] variable scope

2012-08-28 Thread Marc Schwartz
On Aug 28, 2012, at 1:29 PM, Sam Steingold wrote: > At the end of a for loop its variables are still present: > > for (i in 1:10) { > x <- vector(length=1) > } > ls() > > will print "i" and "x". > this means that at the end of the for loop body I have to write > > rm(x) > gc() > >

Re: [R] variable scope

2012-08-28 Thread R. Michael Weylandt
On Tue, Aug 28, 2012 at 1:37 PM, R. Michael Weylandt wrote: > On Tue, Aug 28, 2012 at 1:29 PM, Sam Steingold wrote: >> At the end of a for loop its variables are still present: >> >> for (i in 1:10) { >> x <- vector(length=1) >> } >> ls() >> >> will print "i" and "x". >> this means that

Re: [R] variable scope

2012-08-28 Thread Bert Gunter
Perhaps I'm dense, but huh*? -- Bert *e.g. What are you trying to do? R does it's own garbage collection -- why do you think you need it? And, as a general comment which may or may not be applicable, if you create variables in a function they are local only to the function -- they disappear once t

Re: [R] variable scope

2012-08-28 Thread Rui Barradas
Hello, Maybe local(). Continue your example with #?local local(for (i in 1:10) { x <- vector(length=1) }) ls() # not 'i' nor 'x' Hope this helps, Rui Barradas Em 28-08-2012 19:29, Sam Steingold escreveu: At the end of a for loop its variables are still present: for (i in 1:10) {

Re: [R] variable scope

2012-08-28 Thread R. Michael Weylandt
On Tue, Aug 28, 2012 at 1:29 PM, Sam Steingold wrote: > At the end of a for loop its variables are still present: > > for (i in 1:10) { > x <- vector(length=1) > } > ls() > > will print "i" and "x". > this means that at the end of the for loop body I have to write > > rm(x) > gc() >

[R] variable scope

2012-08-28 Thread Sam Steingold
At the end of a for loop its variables are still present: for (i in 1:10) { x <- vector(length=1) } ls() will print "i" and "x". this means that at the end of the for loop body I have to write rm(x) gc() is there a more elegant way to handle this? Thanks. -- Sam Steingold (http

Re: [R] variable scope for deltavar function from emdbook

2011-10-13 Thread Uwe Ligges
This is R, not S-Plus. In the first two lines you have expr <- as.expression(substitute(fun)) nvals <- length(eval(expr, envir = as.list(meanval))) Simplified example: y <- 0 fn1 <- function(){ y <- 1 fn1sub <- function() print(y) fn1sub() } fn2sub <- function() print(y) fn2 <- fun

Re: [R] variable scope for deltavar function from emdbook

2011-10-11 Thread Ben Bolker
adad gmx.at> writes: > Working example: > -- > library("emdbook") > > fn <- function() > { > browser() > y <- 2 > print(deltavar(y*b2, meanval=c(b2=3), Sigma=1) ) > } > > x <- 2 > print(deltavar(x*b1, meanval=c(b1=3), Sigma=1) ) > y<-3 > > fn() > >

[R] variable scope for deltavar function from emdbook

2011-10-10 Thread adad
Dear all, I want to use the deltavar() function from emdbook. I can use it directly from the command terminal but within a function it behaves weird. Working example: -- library("emdbook") fn <- function() { browser() y <- 2 print(deltavar(y*b2, meanval=c(b2=3), Sigma=1) )

Re: [R] Variable scope in functions - best practices

2011-07-25 Thread Dieter Menne
Noah Silverman wrote: > > > I have several "global" variables that I want to change with a given > function. (The variable has a different value after the function is > called.) > > Berend Hasselman wrote: > > > Maybe this helps > > ?`<<-` > It helps to get the job done, but the OP aske

Re: [R] Variable scope in functions - best practices

2011-07-24 Thread Thomas Lumley
On Mon, Jul 25, 2011 at 4:14 AM, Noah Silverman wrote: > Hi, > > I'm working on coding some more complex things in R and have need to break > much of the logic into functions. > > I have several "global" variables that I want to change with a given > function.  (The variable has a different valu

Re: [R] Variable scope in functions - best practices

2011-07-24 Thread Enrico Schumann
-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] Im Auftrag von Noah Silverman > Gesendet: Sonntag, 24. Juli 2011 18:14 > An: r-help@r-project.org > Betreff: [R] Variable scope in functions - best practices > > Hi, > > I'm working on coding some more com

[R] Variable scope in functions - best practices

2011-07-24 Thread Noah Silverman
Hi, I'm working on coding some more complex things in R and have need to break much of the logic into functions. I have several "global" variables that I want to change with a given function. (The variable has a different value after the function is called.) In other languages like C, this is

Re: [R] Variable scope in functions - best practices

2011-07-24 Thread Berend Hasselman
Noah Silverman wrote: > > Hi, > > I'm working on coding some more complex things in R and have need to break > much of the logic into functions. > > I have several "global" variables that I want to change with a given > function. (The variable has a different value after the function is > call

[R] Variable scope in functions - best practices

2011-07-24 Thread Noah Silverman
Hi, I'm working on coding some more complex things in R and have need to break much of the logic into functions. I have several "global" variables that I want to change with a given function. (The variable has a different value after the function is called.) In other languages like C, this is

[R] Variable scope.

2009-02-28 Thread rkevinburton
I have a question on scope/reference/value type of variables with 'R'. The issue cam up first when I look at the arima code. I see code like: myupARIMA <- function(mod, phi, theta) { . . . . mod } Then armafn <- function(p, trans) { . . . . Z <- upAR

Re: [R] Variable scope R 2.6.1

2008-01-03 Thread Deepayan Sarkar
On 1/2/08, John Fox <[EMAIL PROTECTED]> wrote: > Dear Stefan, > > I don't think that your question was answered. > > If you invoke the formula method for splom(), then your function works; that > is, you can use > > splom(~as.data.frame(rbind(data, outliers)), . . . . > > It looks to me as

Re: [R] Variable scope R 2.6.1

2008-01-02 Thread John Fox
ECTED] > project.org] On Behalf Of Stefan Eichenberger > Sent: January-01-08 6:50 AM > To: r-help@r-project.org > Subject: [R] Variable scope R 2.6.1 > > > I have the following procedure which worked just fine for in R 2.2.0. > Recently I upgraded to 2.6.1 and now ge

[R] Variable scope R 2.6.1

2008-01-01 Thread Stefan Eichenberger
I have the following procedure which worked just fine for in R 2.2.0. Recently I upgraded to 2.6.1 and now get an error: > ScatterOutlier(pass_500_506[1:1000,6:12], marginal_500_506[,6:12]) Error in eval(expr, envir, enclos) : object "out" not found Note that I use the same workspace (and h