I have a data table of teams data by number of players by Region and want to copy to an existing spreadsheet that logs by region by team within certain size category (1, 2, 3-7, etc) in some cases teams are not within the criteria (0) so they do not pull into the data table. How do I ensure the data table continues to show these rows with a 0 rather than removing all together?
Data is available here: https://github.com/rweingarten/Team-Data
team_sizes <- setDT(teams)[, .(sum = sum(uniqueN(player_id))), by = list(REGION, team_ID)]
team_size_3<-subset(team_sizes, team_sizes$sum >= 3 & team_sizes$sum <= 7, by = (team_sizes$REGION))
team_size_three <- setDT(team_size_3)[, uniqueN(team_ID), by = REGION]
This team_size_three results in:
team_size_three
PA 3
GB 1
NE 1
NJ 5
NY 1
OK 2
but it should display:
team_size_three
AR 0
PA 3
GA 1
NE 1
NJ 5
NY 1
OK 2
MD 0
where you can see AR and MD pulling in 0s.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…