I'm having a tough time reproducing your issue. Can you maybe post a sample of your data and we can try with that?
df <- data.frame(
'a' = c(runif(500), runif(500, min = 1, max = 2)),
'status' = c(rep(0, 500), rep(1, 500))
)
tapply(
df$a,
df$status,
mean
)
#> 0 1
#> 0.508250 1.496064
aggregate(
data = df,
. ~ status,
mean
)
#> status a
#> 1 0 0.508250
#> 2 1 1.496064
Created on 2022-07-11 by the reprex package (v1.0.0)