Maybe this is simple but I can\'t find answer on web. I have problem with mean calculation by factors by level. My data looks typicaly:
factor, value a,1 a,2 b,1
Just for fun posting the data.table solution although you probably should do what @lukeA suggested
data.table
library(data.table) A <- setDT(df)[factor == "a", mean(value)] ## [1] 1.5