Can anyone help me about pass by reference of arguments in R functions? I have read about .Alias in base package however it is defunct and there is no replacement for it. Thanks in advance.
Can you tell us what you want to do with 'pass/call by reference'? If you want an R function to alter its argument then it is possible (KalmanLike is an example), but it should only be possible via C code. And if you know enough to do that, you probably would not be asking (and definitely not be asking on R-help rather than R-devel). On Tue, 19 Dec 2006, biter bilen wrote:> Can anyone help me about pass by reference of arguments in R functions? > > I have read about .Alias in base package however it is defunct and there > is no replacement for it.That's not a fair summary of the help entry for .Alias. -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
a = 9 b = 8 print (a) print (b) fa<-function(bS, aV) { aV <<- 3 assign(bS,3,env = .GlobalEnv) } fa("b", a) print (a) #9 print (b) #3 #only this call is ok ----- Original Message ---- From: Prof Brian Ripley <ripley at stats.ox.ac.uk> To: biter bilen <biterbilen at yahoo.com> Cc: r-help at stat.math.ethz.ch Sent: Wednesday, December 20, 2006 11:04:08 AM Subject: Re: [R] call by reference Can you tell us what you want to do with 'pass/call by reference'? If you want an R function to alter its argument then it is possible (KalmanLike is an example), but it should only be possible via C code. And if you know enough to do that, you probably would not be asking (and definitely not be asking on R-help rather than R-devel). On Tue, 19 Dec 2006, biter bilen wrote:> Can anyone help me about pass by reference of arguments in R functions? > > I have read about .Alias in base package however it is defunct and there > is no replacement for it.That's not a fair summary of the help entry for .Alias. -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
There is no support for 'call by reference' in the S language, and this is intentionally, but you can use environments to imitate it, cf. ?environment. See also the R.oo package. /Henrik On 12/20/06, biter bilen <biterbilen at yahoo.com> wrote:> Can anyone help me about pass by reference of arguments in R functions? > > I have read about .Alias in base package however it is defunct and there is no replacement for it. > > Thanks in advance. > > ______________________________________________ > R-help at stat.math.ethz.ch 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 commented, minimal, self-contained, reproducible code. >
Maybe Matching Threads
- kalman filter
- KalmanLike: missing exogenous factor?
- [LLVMdev] undefined reference to 'llvm_gcda_start_file', 'llvm_gcda_emit_arcs', etc
- [LLVMdev] undefined reference to 'llvm_gcda_start_file', 'llvm_gcda_emit_arcs', etc
- [LLVMdev] undefined reference to 'llvm_gcda_start_file', 'llvm_gcda_emit_arcs', etc