[R] Warning message when returning multiple items
Gavin Simpson
gavin.simpson at ucl.ac.uk
Mon Jan 30 19:54:17 CET 2006
On Mon, 2006-01-30 at 10:35 -0800, Krish Krishnan wrote:
> In my function I am trying to return multiple computed items
> (separated by commas). The function does what I need, but I get a
> warning message that multi-argument returns are deprecated. Is this a
> warning I should heed, or is there a more elegant and warning free way
> of achieving the same end? Thanks
foo <- function(x)
{
x5 <- x * 5
rootx <- sqrt(x)
squaredx <- x^2
return(list(x5 = x5, rootx = rootx, squaredx = squaredx))
}
> foo(9)
$x5
[1] 45
$rootx
[1] 3
$squaredx
[1] 81
HTH
G
--
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
Gavin Simpson [T] +44 (0)20 7679 5522
ENSIS Research Fellow [F] +44 (0)20 7679 7565
ENSIS Ltd. & ECRC [E] gavin.simpsonATNOSPAMucl.ac.uk
UCL Department of Geography [W] http://www.ucl.ac.uk/~ucfagls/cv/
26 Bedford Way [W] http://www.ucl.ac.uk/~ucfagls/
London. WC1H 0AP.
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
More information about the R-help
mailing list