Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create an ellipsis (...) from list

Tags:

r

Is it possible to create a ellipsis (...) from a list? The idea is to be able to do something like:

mylist <- list(a=1,b=2,c=3)
myellipsis <- create_ellipsis(mylist)
print(switch('a', myellipsis)) # output 1
like image 989
papirrin Avatar asked Aug 31 '13 07:08

papirrin


1 Answers

You want do.call, which can pass the content of a list to a functions ... argument:

do.call(function(...) print(switch('a', ...)), mylist)
like image 184
Roland Avatar answered Nov 15 '22 01:11

Roland