Calculating cumulative standard deviation by group using R
<p>I am pretty new to R and wanted to calculate the cumulative standard deviation by group in R. I have a data frame D which has an ID for visitor and the corresponding time on page (top) spent in each page as below</p>

<pre><code>ID   top
v1   2.3  
v1   4.8
v1   10.2
v2   16.2
v2   12.2
v2   14.3
v2   12.4
v3   8.2
v3   8.8
</code></pre>

<p>The output needs to look like this</p>

<pre><code>ID   top  cum_sd
v1   2.3  
v1   4.8   1.76
v1   10.2  4.03
v2   16.2
v2   12.2  2.82
v2   14.3  2.00
v2   12.4  1.15
v3   8.2   
v3   8.8   0.42
</code></pre>

<p>Thank you for the help in advance.</p>