The code aggregate(df$var, list(df$id), runs.test) returns the test statistic (standard normal) of the variance of a given function.
Normally, the code runs.test(data)$p.value gives you the p-value. But aggregate(df$var, list(df$id), runs.test(df$var)$p.value) gives the the error:
Error in match.fun(FUN) : 
  'runs.test(df$var)$p.value' is not a function, character or symbol
How can I use aggregate to give me the p-value?
aggregate(df$var, list(df$id), function(x) runs.test(x)$p.value)