单元季度目标归集县区日周月季
{
udf_aim_count_town <- function(df=aim_unit_tb,x){
y <- df[,.(aim_amount=sum(get(x))),by="zone_town"] # 总目标
y[,aim_amount:=round(aim_amount,0)]
y[,aim_day := round(aim_amount/92,2)] # 日目标
y[,aim_week := aim_day * Date_shift_days] # 区间目标
y[,aim_month := aim_day * day(ymd(paste0(Date_year,Date_labs)))] # 月序时目标
y[,aim_quart := aim_day * (Date_quart_day+1)] # 季度目标
return(y)
}
}
aim_town_tb <- udf_aim_count_town(aim_unit_tb , "aim_mob" )