我无法从C ++函数调用match.call()
。在下面的示例中,match_call()
C ++函数在将其参数转发到match.call()
时失败。我错过了什么?
match_call <-
Rcpp::cppFunction(
'
SEXP match_call(SEXP definition, SEXP call) {
Function m("match.call", R_BaseEnv);
return m(definition, call);
}
')
match.call(function(a = 1, b = 2){}, quote(fun(b = 4, 3)))
## fun(a = 3, b = 4)
match_call(function(a = 1, b = 2){}, quote(fun(b = 4, 3)))
## error: could not find function "fun"
根据@nicola的建议,添加quote()
有助于:
return m(definition, Rf_lang2(R_QuoteSymbol, call));
这有效,但无法解释机制。