-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Progress towards #24
- Loading branch information
Showing
3 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#' League transactions | ||
#' | ||
#' Summary of transactions and roster changes made during a season by team. | ||
#' | ||
#' @inheritParams ffl_api | ||
#' @return A data frame of transaction counts by team. | ||
#' @examples | ||
#' moves_summary(leagueId = "42654852") | ||
#' @importFrom tibble as_tibble | ||
#' @export | ||
moves_summary <- function(leagueId = ffl_id(), leagueHistory = FALSE, ...) { | ||
dat <- ffl_api(leagueId, leagueHistory, view = "mTeam", ...) | ||
if (leagueHistory) { | ||
out <- rep(list(NA), length(dat$teams)) | ||
for (i in seq_along(dat$members)) { | ||
out[[i]] <- out_trans( | ||
teams = dat$teams[[i]], | ||
y = dat$seasonId[i], | ||
w = dat$scoringPeriodId[i] | ||
) | ||
} | ||
} else { | ||
out <- out_trans( | ||
teams = dat$teams, | ||
y = dat$seasonId, | ||
w = dat$scoringPeriodId | ||
) | ||
} | ||
return(out) | ||
} | ||
|
||
out_trans <- function(teams, y = NULL, w = NULL) { | ||
teams$transactionCounter$matchupAcquisitionTotals <- NULL | ||
x <- data.frame( | ||
seasonId = y, | ||
scoringPeriodId = w, | ||
teamId = teams$id, | ||
abbrev = factor(teams$abbrev, levels = teams$abbrev), | ||
waiverRank = teams$waiverRank, | ||
teams$transactionCounter | ||
) | ||
as_tibble(x) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.