Description Usage Arguments Examples
Handles functions with multiple outputs better without messy intermediate list-objects.
1 | return.multiple(map, f)(<INPUTARGS>)
|
map |
A list mapping external names to local-names of return-entities in output of f. |
f |
Function which returns a list-objet as output. |
<INPUTARGS> |
Input arguments for f. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | ## Not run:
infos <- function(firstname='',surname='',age=0) {
underage <- (age < 18);
fullname <- gsub('^\\s+|\\s+$', '', print0(firstname,' ',surname));
return(list(
voter = !underage,
fullname = fullname,
validname = !(fullname == '')
));
};
return.multiple(list(valid='validname', isvoter='voter'), f)(firstname='Richard', surname='Feynman', age=100);
# equivalent to:
obj <- f(firstname='Richard', surname='Feynman', age=100);
valid <- obj$validname;
isvoter <- obj$voter;
## End(Not run)
## Not run:
f <- function(<INPUTARGS>) {
·
·
·
return(list(
localoutput1 = <RETURN-OUTPUT1>,
localoutput2 = <RETURN-OUTPUT2>,
·
·
));
};
·
·
·
return.multiple(list(var1=localoutput1, var2=localoutput2, ...), f)(<INPUTARGS>);
# equivalent to:
obj <- f(<INPUTARGS>);
var1 <- obj$localoutput1;
var2 <- obj$localoutput1;
·
·
·
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.