Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I read answers and comments and I see that few things weren't mentioned:</p> <ol> <li><p><code>data.frame</code> uses <code>list(...)</code> version. Fragment of the code:</p> <pre><code>object &lt;- as.list(substitute(list(...)))[-1L] mrn &lt;- is.null(row.names) x &lt;- list(...) </code></pre> <p><code>object</code> is used to do some magic with column names, but <code>x</code> is used to create final <code>data.frame</code>.<br> For use of unevaluated <code>...</code> argument look at <code>write.csv</code> code where <code>match.call</code> is used.</p></li> <li><p>As you write in comment result in Dirk answer is not a list of lists. Is a list of length 4, which elements are <code>language</code> type. First object is a <code>symbol</code> - <code>list</code>, second is expression <code>1:10</code> and so on. That explain why <code>[-1L]</code> is needed: it removes expected <code>symbol</code> from provided arguments in <code>...</code> (cause it is always a list).<br> As Dirk states <code>substitute</code> returns "parse tree the unevaluated expression".<br> When you call <code>my_ellipsis_function(a=1:10,b=11:20,c=21:30)</code> then <code>...</code> "creates" a list of arguments: <code>list(a=1:10,b=11:20,c=21:30)</code> and <code>substitute</code> make it a list of four elements:</p> <pre><code>List of 4 $ : symbol list $ a: language 1:10 $ b: language 11:20 $ c: language 21:30 </code></pre> <p>First element doesn't have a name and this is <code>[[1]]</code> in Dirk answer. I achieve this results using:</p> <pre><code>my_ellipsis_function &lt;- function(...) { input_list &lt;- as.list(substitute(list(...))) str(input_list) NULL } my_ellipsis_function(a=1:10,b=11:20,c=21:30) </code></pre></li> <li><p>As above we can use <code>str</code> to check what objects are in a function.</p> <pre><code>my_ellipsis_function &lt;- function(...) { input_list &lt;- list(...) output_list &lt;- lapply(X=input_list, function(x) {str(x);summary(x)}) return(output_list) } my_ellipsis_function(a=1:10,b=11:20,c=21:30) int [1:10] 1 2 3 4 5 6 7 8 9 10 int [1:10] 11 12 13 14 15 16 17 18 19 20 int [1:10] 21 22 23 24 25 26 27 28 29 30 $a Min. 1st Qu. Median Mean 3rd Qu. Max. 1.00 3.25 5.50 5.50 7.75 10.00 $b Min. 1st Qu. Median Mean 3rd Qu. Max. 11.0 13.2 15.5 15.5 17.8 20.0 $c Min. 1st Qu. Median Mean 3rd Qu. Max. 21.0 23.2 25.5 25.5 27.8 30.0 </code></pre> <p>It's ok. Lets see <code>substitute</code> version:</p> <pre><code> my_ellipsis_function &lt;- function(...) { input_list &lt;- as.list(substitute(list(...))) output_list &lt;- lapply(X=input_list, function(x) {str(x);summary(x)}) return(output_list) } my_ellipsis_function(a=1:10,b=11:20,c=21:30) symbol list language 1:10 language 11:20 language 21:30 [[1]] Length Class Mode 1 name name $a Length Class Mode 3 call call $b Length Class Mode 3 call call $c Length Class Mode 3 call call </code></pre> <p>Isn't what we needed. You will need additional tricks to deal with these kind of objects (as in <code>write.csv</code>).</p></li> </ol> <p>If you want use <code>...</code> then you should use it as in Shane answer, by <code>list(...)</code>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload