title: ddply multiple function arguments + naming
body: <p>Browsing other questions I have almost solved my problem but failing at the last hurdle...</p>
  
  <p>using R</p>
  
  <p>I have a dataframe (d) of which I pass through a function (fd) with ddply from the plyr package, this returns a dataframe as expected. In my actual dataframe I have a large number of variables I want to pass into the function, rather than calling it multiple times, I would also like to give relevant col.names to the output datatable. Tried to do step by step of workings below... </p>
  
  <p>Sample data:</p>
  
  <pre><code>d&lt;-structure(list(date.time = structure(c(1367943040, 1367950947, 
  1367950965, 1367950987, 1367951028, 1367951045, 1367959536, 1367960275, 
  1367960413, 1367985859, 1368005216, 1368005233, 1368011698, 1368011931, 
  1368012615, 1368033855), tzone = "", class = c("POSIXct", "POSIXt"
  )), station = c("L5", "L5", "L5", "L5", "L5", "L5", "L7", "L7", 
  "L7", "L7", "L5", "L5", "L7", "L7", "L7", "L7"), code = c(10891, 
  10891, 10891, 10891, 10891, 10891, 10891, 10891, 10891, 10891, 
  10888, 10888, 10888, 10888, 10888, 10888)), .Names = c("date.time", 
  "station", "code"), row.names = c(2421L, 2466L, 2467L, 2468L, 
  2469L, 2470L, 2472L, 2473L, 2474L, 2812L, 2837L, 2838L, 2859L, 
  2860L, 2861L, 3219L), class = "data.frame")
  </code></pre>
  
  <p>I have a function to find the first occurance of an event and return the datetime when this event occoured:</p>
  
  <pre><code>fd&lt;- function(x, var){
    time&lt;- (as.POSIXct(x$date.time [x$station == var] [1]))
    paste (as.POSIXct (time, origin="1970-1-1", tz='UTC'))
  }
  </code></pre>
  
  <p>I pass this to the dataframe:</p>
  
  <pre><code>ddply(d,'code',fd,"L7")
  </code></pre>
  
  <p>Finds datetime where station "L7" is first recorded and returns dataframe:</p>
  
  <pre><code>code                  V1
  1 10888 2013-05-08 12:14:58
  2 10891 2013-05-07 21:45:36
  </code></pre>
  
  <p>Is there a more efficient way of calling multiple function arguments rather than writing multiple function calls. Also to name the column, above "V1" would read "L7" something like this (does not work)... </p>
  
  <pre><code>ddply(d,'code',fd,c("L7", "F5"))   
  </code></pre>
  
  <p>What i have so far and works to an extent is:</p>
  
  <pre><code>data.frame(  
    ddply(d,'code',fd,"L7"),
    ddply(d,'code',fd,"L5")) 
  </code></pre>
  
  <p>Returns:</p>
  
  <pre><code>   code          V1          code.1        V1.1
  1 10888 2013-05-08 12:14:58  10888 2013-05-08 10:26:56
  2 10891 2013-05-07 21:45:36  10891 2013-05-07 17:10:40
  </code></pre>
  
  <p>As you can see "code" is repeated </p>
  
  <p>And colnames are inappropriate, what I would like in the end is a data.frame with:</p>
  
  <pre><code>  code           M1                 M2
  1 10888 2013-05-08 12:14:58  2013-05-08 10:26:56
  2 10891 2013-05-07 21:45:36  2013-05-07 17:10:40
  </code></pre>