I have a dataset that is has a number of groups.
I have to calculate two things:
The average value of some data per group - which I have done with the following code:
var results = from res in dt.AsEnumerable()
group res by res.Field<string>(key)
into grp
orderby Convert.ToInt32(grp.Key)
select new
{
date = grp.Key,
sum = grp.Average(r => Convert.ToDouble(r.Field<string> (average)))
};
I also need to calculate the standard deviation of the values for each group, so for each individual group, I need to create an array or list of the individual results per group. How could I do this with LINQ?
Thanks.
EDIT: I appreciate my question my be a little vague; I know how to calculate the standard deviation, I would like to know how to extract the list of values for each group(as above) to allow the calculation to be performed. Thanks.