如果下面有df
,我需要计算两个metric
组team
和tm1
上变量tm2
的分布之间的相似度每locid
个基础
set.seed(100)
df <- data.frame(
locid = sample(c(1111,1122,1133), 20, replace=TRUE),
day = sample(c(1:3), 20, replace=TRUE),
hour = sample(c(1:4), 20, replace=TRUE),
team = sample(c("tm1", "tm2", "tm3"), 20, replace=TRUE),
metric = sample(1:5, 20, replace=TRUE )
)