title: doing a plyr operation on every row of a data frame in R
body: <p>I like the plyr syntax. Any time I have to use one of the *apply() commands I end up kicking the dog and going on a 3 day bender. So for the sake of my dog and my liver, what's concise syntax for doing a ddply operation on every row of a data frame?</p>
  
  <p>Here's an example that works well for a simple case:</p>
  
  <pre><code>x &lt;- rnorm(10)
  y &lt;- rnorm(10)
  df &lt;- data.frame(x,y)
  ddply(df,names(df) ,function(df) max(df$x,df$y))
  </code></pre>
  
  <p>that works fine and gives me what I want. But if things get more complex this causes plyr to get funky (and not like Bootsy Collins) because plyr is chewing on making "levels" out of all those floating point values</p>
  
  <pre><code>x &lt;- rnorm(1000)
  y &lt;- rnorm(1000)
  z &lt;- rnorm(1000)
  myLetters &lt;- sample(letters, 1000, replace=T)
  df &lt;- data.frame(x,y, z, myLetters)
  ddply(df,names(df) ,function(df) max(df$x,df$y))
  </code></pre>
  
  <p>on my box this chews for a few minutes and then returns:</p>
  
  <pre><code>Error: memory exhausted (limit reached?)
  In addition: Warning messages:
  1: In paste(rep(l, each = ll), rep(lvs, length(l)), sep = sep) :
    Reached total allocation of 1535Mb: see help(memory.size)
  2: In paste(rep(l, each = ll), rep(lvs, length(l)), sep = sep) :
    Reached total allocation of 1535Mb: see help(memory.size)
  </code></pre>
  
  <p>I think I am totally abusing plyr and I am not saying this is a bug in plyr, but rather abusive behavior by me (liver and dog notwithstanding).</p>
  
  <p>So in short, is there syntax shortcut for using ddply to operate on every row as a substitute for <code>apply(X, 1, ...)</code>?</p>
  
  <p>The workaround I've been using is to create a "key" that gives a unique value for every row and then I can join back to it. </p>
  
  <pre><code> x &lt;- rnorm(1000)
   y &lt;- rnorm(1000)
   z &lt;- rnorm(1000)
   myLetters &lt;- sample(letters, 1000, replace=T)
   df &lt;- data.frame(x,y, z, myLetters)
    #make the key
   df$myKey &lt;- 1:nrow(df)
   myOut &lt;- merge(df, ddply(df,"myKey" ,function(df) max(df$x,df$y)))
    #knock out the key
   myOut$myKey &lt;- NULL
  </code></pre>
  
  <p>But I keep thinking that "There Has to Be a Better Way"</p>
  
  <p>Thanks! </p>