require(inline)
func <- cxxfunction(, 'return Rcpp::wrap( qnorm(0.95,0.0,1.0) );' ,plugin="Rcpp")
Run Code Online (Sandbox Code Playgroud)
错误:没有用于调用'qnorm5(double,int,int)'的匹配函数
require(inline)
func <- cxxfunction(, 'return Rcpp::wrap( qnorm(0.95, 0.0, 1.0, 1, 0) );'
,plugin="Rcpp")
Run Code Online (Sandbox Code Playgroud)
错误:没有匹配函数来调用'qnorm5(double,double,double,int,int)'
require(inline)
code <-'
double a = qnorm(0.95, 0.0, 1.0);
return Rcpp::wrap( a );
'
func <-
cxxfunction(, code ,plugin="Rcpp")
func()
Run Code Online (Sandbox Code Playgroud)
错误:没有匹配函数来调用'qnorm5(double,double,double)'
如何在Rcpp上使用qnorm?
通过使用mean和sd参数double作为错误消息显示 - 所以尝试这是一个完整的例子
library(inline)
f <- cxxfunction(signature(xs="numeric", plugin="Rcpp", body='
Rcpp::NumericVector x(xs);
return Rcpp::wrap(Rcpp::qnorm(x, 1.0, 0.0));
')
Run Code Online (Sandbox Code Playgroud)
并查看示例和单元测试 - 我只是在单元测试文件中查看了这个文件runit.stats.R,其中包含许多针对这些统计'Rcpp sugar'函数的测试用例.
编辑于2012-11-14: 今天发布了Rcpp 0.10.0,R::qnorm(double, double, double, int, int)如果你想使用C风格的代码,你可以调用签名Rmath.h.Rcpp糖仍然为您提供矢量化版本.