k5cents / fflr

Get ESPN fantasy football data in R
https://k5cents.github.io/fflr/
GNU General Public License v3.0
22 stars 7 forks source link

transaction_counter when leagueHistory = TRUE results in factor level [3] duplication error. #47

Open KevinLeone opened 8 months ago

KevinLeone commented 8 months ago

transaction_counter(leagueHistory=TRUE) results in following error: Error in `levels<-`(`*tmp*`, value = as.character(levels)) : factor level [3] is duplicated

traceback as follows:

  1. out_trans(teams = dat$teams[[i]], y = dat$seasonId[i], w = dat$scoringPeriodId[i])
  2. data.frame(seasonId = y, scoringPeriodId = w, teamId = teams$id,
  3. abbrev = factor(teams$abbrev, levels = teams$abbrev), waiverRank = teams$waiverRank, teams$transactionCounter)
  4. factor(teams$abbrev, levels = teams$abbrev)

Went to debug, but out_trans has no supported rdocumentation/cannot be loaded from installation. Would gladly take a bug fix to just pull each seasonId individually.

k5cents commented 1 month ago

I believe this is less a problem with transaction_counter() and more an issue with having duplicate team abbreviations. The error should come up with other functions that produce an abbrev factor column.

Abbreviations are factors in the order of teamId such that they always show up in the same order even if they change text.

The solution (without changing team abbreviations) is probably for the package to just not try to make these factors if they aren't unique.