title: How to apply spline() to a large dataframe
body: <p>I am a newbie to R and I am trying to apply <code>smooth.spline()</code> to a large dataframe. I've looked at the related threads ("Apply a list of n functions to each row of a dataframe,", "How to apply a spline basis matrix",...). Here is my dataframe and what I've tried so far:</p>
  
  <pre><code>&gt; dim(mUnique)  
  [1] 4565    9  
  &gt; str(mUnique)  
  'data.frame':   4565 obs. of  9 variables:  
   $ Group.1: Factor w/ 4565 levels "mal_mito_1","mal_mito_2",..: 1 2 3 4 5 6 7 8 9 10 ...  
   $ h0     : num  0.18 -0.025 0.212 0.015 0.12 ...  
   $ h6     : num  -0.04 -0.305 -0.188 -0.185 -0.09 ...  
   $ h12    : num  -0.86 -1.1 -1.01 -1.04 -0.91 ...  
   $ h18    : num  -0.73 -1.215 -1.222 -0.355 -0.65 ...  
   $ h24    : num  0.04 0.025 -0.143 0.295 0.09 ...  
   $ h30    : num  -0.14 1.275 0.732 -0.015 -0.27 ...  
   $ h36    : num  1.44 1.795 1.627 0.385 0.91 ...  
   $ h42    : num  1.49 1.385 1.397 0.305 1.12 ...  
  
  &gt; head(mUnique)  
            ID      h0      h6     h12     h18     h24     h30    h36    h42  
  1      mal_mito_1  0.1800 -0.0400 -0.8600 -0.7300  0.0400 -0.1400 1.4400 1.4900  
  2      mal_mito_2 -0.0250 -0.3050 -1.1050 -1.2150  0.0250  1.2750 1.7950 1.3850  
  3      mal_mito_3  0.2125 -0.1875 -1.0075 -1.2225 -0.1425  0.7325 1.6275 1.3975  
  4 mal_rna_10_rRNA  0.0150 -0.1850 -1.0450 -0.3550  0.2950 -0.0150 0.3850 0.3050  
  5 mal_rna_11_rRNA  0.1200 -0.0900 -0.9100 -0.6500  0.0900 -0.2700 0.9100 1.1200  
  6 mal_rna_14_rRNA  0.0200 -0.0200 -0.8400 -0.6600  0.1700 -0.0900 0.6200 0.0800 
  </code></pre>
  
  <p>I can apply <code>smooth.spline</code> on each row independently and it looks good with <code>spline()</code> so far (I want 48 points. I'll figure out later how to do it with <code>smoooth.spline</code> <code>spar</code>):</p>
  
  <pre><code>&gt; time &lt;- c(0,6,12,18,24,30,36,42)  
  &gt; plot(time, mUnique[1, 2:9])  
  &gt; smooth &lt;- smooth.spline(time, mUnique[1, 2:9])  
  &gt; lines(smooth, col="blue")  
  &gt; splin &lt;-spline(time, mUnique[1, 2:9], n=48)  
  &gt; lines(splin, col="blue")  
  </code></pre>
  
  <p>My question is I suppose basic, but how to I apply <code>smooth.spline()</code> or <code>spline()</code> to the whole dataframe, and get back a matrix 4565 * 49 where I have the coordinates for each knots of the smoothed spline?  I don't really care about plotting that data.</p>
  
  <p>I tried:</p>
  
  <pre><code>&gt; smooth &lt;- smooth.spline(time, mUnique[, 2:9]|factor(ID))
  </code></pre>
  
  <p>Now, don't know what to do. Is that a matter of making loops?</p>
  
  <p>Thank you in advance</p>