On Wed, 17 Feb 2010, Randall Wrong wrote:
Dear R users,
I have multi-argument returns in a function and I am warned by the program
they are deprecated.
Defunct as from the next R release.
I have found this in the R-help archives :
in 2001!
http://tolstoy.newcastle.edu.au/R/help/01c/0319.html
http://tolstoy.newcastle.edu.au/R/help/01c/0356.html
Since I am not too good at programming, the list solution seems the better
one for me. It is also the one advocated by Kevin Murphy.
So rather than writing return(x,y,z), I should write at the end of my
function :
return(list(x=x,y=y,z=z)) is the preferred replacement.
(As the help page for return() has long said.)
g=function() {
#...
result=list(x,y,z)
return(result)
}
Is that correct ?
Then shoud l use g[1] or g[[1]] ?
No change is needed (I think you mean g()$x etc) as return(x,y,z) and
return(list(x=x,y=y,z=z)) are identical in their effects.
Thank you for you help.
Randall
--
Brian D. Ripley, rip...@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
______________________________________________
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 commented, minimal, self-contained, reproducible code.