Getting started: Help with BY function (conditional functions)

Here's how my dataset (time series of a stock) looks like:

Date Tick Open High Low Close Volume
|1|01/02/1991|931|3.34|3.34|3.34|3.34|113441|
|2|01/02/1991|933|3.32|3.32|3.32|3.32|113098|
|3|01/02/1991|934|3.32|3.32|3.32|3.32|39070|
|4|01/02/1991|937|3.32|3.32|3.32|3.32|65117|
|5|01/02/1991|939|3.32|3.32|3.32|3.32|5826|
|6|01/02/1991|941|3.32|3.32|3.32|3.32|2399|
|7|01/02/1991|943|3.32|3.32|3.32|3.32|68544|
|8|01/02/1991|948|3.32|3.32|3.32|3.32|69230|
|9|01/02/1991|949|3.32|3.32|3.32|3.32|6854|
|10|01/02/1991|952|3.32|3.32|3.32|3.32|7882|
|11|01/02/1991|954|3.34|3.34|3.34|3.34|3769|
|12|01/02/1991|956|3.34|3.34|3.34|3.34|38042|
|13|01/02/1991|957|3.34|3.34|3.34|3.34|41812|
|14|01/02/1991|1002|3.34|3.34|3.34|3.34|2399|
|15|01/02/1991|1008|3.34|3.34|3.34|3.34|685|
|16|01/02/1991|1011|3.34|3.34|3.34|3.34|342|
|17|01/02/1991|1012|3.34|3.34|3.34|3.34|2399|
|18|01/02/1991|1014|3.34|3.34|3.34|3.34|10281|
|19|01/02/1991|1017|3.34|3.34|3.34|3.34|3427|
|20|01/02/1991|1019|3.34|3.36|3.34|3.36|5483|
|21|01/02/1991|1021|3.36|3.36|3.36|3.36|3427|
|22|01/02/1991|1022|3.34|3.34|3.34|3.34|342|
|23|01/02/1991|1023|3.34|3.36|3.34|3.36|5140|

After some more ticks, around 1550, another day begins.

I need to calculate daily variance for the stocks, that is, for each day, I'll fold the daily data into one number, which is the variance. I'm new to R and have no idea how to do this. Can someone help?

I know how to calculate the variance, just don't know how to condition this to the Date column.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.