title: R: pass a vector of symbols into a function instead of a long argument list
body: <p>I'm writing an R package that calls C code with the .C() function. I need to pass over 50 arguments into .C(), which seriously bloats my code and is prone to error. Rather than type </p>
  
  <pre><code>output &lt;- .C("my_dynlib", arg2, arg3, arg4, arg5, arg6, ..., arg53)
  </code></pre>
  
  <p>I would rather have a character vector <code>myNames</code> of additional arguments to send to .C() and do something like</p>
  
  <pre><code>f &lt;- Vectorize(as.symbol, "x")
  mySymbols &lt;- f(myNames)
  output &lt;- .C("my_dynlib", mySymbols)
  </code></pre>
  
  <p>But this isn't quite what I want because mySymbols is a list. Is there a way to compactly pass a collection of arguments to a function that I don't want to rewrite?</p>
  
  <p>Footnote: I'm guessing that some of you will suggest passing more complicated arguments with .Call, .External, or Rcpp, but that's more overhaul than I want to deal with right now.</p>
  
  <hr>
  
  <p><strong>Edit: what if I want <code>myNames</code> to point to slots in an s3 or s4 object?</strong></p>
  
  <p>Suppose I want to use symbols that refer to class slots in a data frame.</p>
  
  <pre><code>&gt; y = data.frame(a = 1:4, b = 5:8)
  &gt; myNames = paste("y@", slotNames(y), sep = "")
  &gt; mySymbols = lapply(myNames, as.symbol)
  &gt; str(mySymbols)
  List of 4
   $ : symbol y@.Data
   $ : symbol y@names
   $ : symbol y@row.names
   $ : symbol y@.S3Class
  </code></pre>
  
  <p>I use do.call like @josilber said, but do.call doesn't recognize the symbols</p>
  
  <pre><code>&gt; do.call(print, mySymbols)
  Error in (function (x, ...)  : object 'y@.Data' not found
  </code></pre>
  
  <p>even though I can use those symbols manually.</p>
  
  <pre><code>&gt; y@.Data
  [[1]]
  [1] 1 2 3 4
  
  [[2]]
  [1] 5 6 7 8 
  </code></pre>