You should look at the package data.table
for faster aggregation operations on large data frames. For your problem, the solution would look like:
library(data.table)
data_t = data.table(data_tab)
ans = data_t[,list(A = sum(count), B = mean(count)), by = 'PID,Time,Site']