I need to calculate the within and between run variances from some data as part of developing a new analytical chemistry method. I also need confidence intervals from this data
If you want to apply a function (such as var) across a factor such as Run or Rep, you can use tapply:
var
Run
Rep
tapply
> with(variance, tapply(Value, Run, var)) 1 2 3 4 0.005833333 0.310000000 0.610000000 0.043333333 > with(variance, tapply(Value, Rep, var)) 1 2 3 0.48562500 0.88729167 0.05583333