R/members.R

Defines functions out_member league_members

Documented in league_members

#' Fantasy league teams
#'
#' The teams in a league and their owners.
#'
#' @inheritParams ffl_api
#' @examples
#' league_members(leagueId = "42654852")
#' @return A dataframe (or list) with league members.
#' @family league functions
#' @export
league_members <- function(leagueId = ffl_id(), leagueHistory = FALSE, ...) {
  dat <- ffl_api(
    leagueId = leagueId,
    leagueHistory = leagueHistory,
    ...
  )
  if (leagueHistory && is.list(dat$teams)) {
    names(dat$members) <- dat$seasonId
    lapply(dat$members, out_member)
  } else {
    out_member(dat$members)
  }
}

out_member <- function(x) {
  x <- change_names(x, "id", "memberId")
  as_tibble(x)
}

Try the fflr package in your browser

Any scripts or data that you put into this service are public.

fflr documentation built on Sept. 14, 2023, 9:10 a.m.