我无法访问R包中的函数。函数名称为get_league_listing
,包名称为Rdota2
。它显示以下错误:
Error in (function (..., deparse.level = 1, make.row.names = TRUE, stringsAsFactors = default.stringsAsFactors()) :
numbers of columns of arguments do not match
这是使用的命令:
get_league_listing(dota_id = 570, language = "en", key = NULL)
请帮帮我。
答案 0 :(得分:0)
这用于返回data.frame,但是Valve决定其中一个联盟不应该有一个描述字段,这使得代码的rbind
部分(正如@ r2evans在评论中正确提到的那样)在下面失败(来自get_league_listing
的代码),因为列数不同:
args <- list(key = key, language = 'en')
dota_result <- get_response(570, 'GetLeagueListing', 'IDOTA2Match', 1, args)
#the below fails
dota_result$content <-
do.call(rbind.data.frame, c(dota_result$content[[1]][[1]], stringsAsFactors = FALSE))
Error in (function (..., deparse.level = 1, make.row.names = TRUE, stringsAsFactors = default.stringsAsFactors()) :
numbers of columns of arguments do not match
这是罪魁祸首btw(这里应该有一个描述元素,以便rbind
能够工作):
> dota_result$content[[1]][[1]][[1651]]
$name
[1] "The International 2017 Open Qualifiers"
$leagueid
[1] 5498
$tournament_url
[1] "http://www.dota2.com"
$itemdef
[1] 17377
解决方案,直到我更新软件包,是使用响应,然后可能data.table转换为data.frame / data.table:
library(data.table)
#if your key is stored using the method described at the vignette
#leave it as NULL, otherwise add your key.
args <- list(key = key, language = 'en')
dota_result <- get_response(570, 'GetLeagueListing', 'IDOTA2Match', 1, args)
rbindlist(dota_result$content[[1]][[1]], fill = TRUE, use.names = TRUE)
将返回:
name leagueid
1: Dota 2 Just For Fun 1212
2: joinDOTA League Season 3 1640
3: Killing Spree: North America 25
4: Wild Cards West 2
5: Wild Cards East 3
---
1683: GESC: Thailand 9663
1684: Dota 2 Asia Championships 2018 9643
1685: ESL One Genting 2018 8093
1686: Corsair DreamLeague season 9 9683
1687: StarLadder ImbaTV Invitational Season 5 9908
description
1: 64 of the best Brazilian amateur teams compete to become the winner of the first Dota 2 Just For Fun tournament.
2: The global Dota 2 league for everyone. Featured are all of the matches from division 1 and 2. There are three leagues: Europe, America, and Asia. The top 10 from each league meet in the premier division. $1.00 from each ticket purchased will go directly into the prizepool.