Error in eval(expr, envir, enclos) in getMarket from package betfair

222 Views Asked by At

I'm having some problems with the getMarket function from package betfair. Here's the gist of it:

g <- function(x){
    getMarket(x)
}
g(110501389)

This throws:

Error in eval(expr, envir, enclos) : object 'x' not found

g is in the global environment, and getMarket is from namespace:betfair.

I've never had this problem with other packages (e.g., mlogit). Any ideas?

traceback() gives:

10: eval(expr, envir, enclos)
9: eval(parameters[[j]])
8: FUN(1:2[[1L]], ...)
7: lapply(1:length(parameters), function(j) { ...
6: paste(lapply(1:length(parameters), function(j) { ...
5: .list2xml(parameters, allowNull)
4: paste(body, .list2xml(parameters, allowNull), sep = "")
3: .bfapi(match.call(), service = service)
2: getMarket(y) at .active-rstudio-document#2
1: g(110501389)
1

There are 1 best solutions below

2
On

It is a bug in betfair::getMarket() in the first line: .bfapi(match.call(), service = service)

match.call() when called from g() gives: getMarket(marketId = x) But x is not defined in getMarket().

To illustrate this, try this wrapper:

 h <- function(marketId){
   getMarket(marketId)
 }
 h(110501389)