r - 如何在 Rcpp 上使用 qnorm?

标签 r inline rcpp

require(inline)
func <- cxxfunction(, 'return Rcpp::wrap( qnorm(0.95,0.0,1.0) );' ,plugin="Rcpp")

错误:没有匹配的函数来调用“qnorm5(double, int, int)”

require(inline)
func <- cxxfunction(, 'return Rcpp::wrap( qnorm(0.95, 0.0, 1.0, 1, 0) );' 
                   ,plugin="Rcpp")

错误:没有匹配的函数来调用“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()

错误:没有匹配的函数来调用“qnorm5(double, double, double)”

如何在 Rcpp 上使用 qnorm?

最佳答案

通过将 meansd 参数设为 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));
')

并查看示例和单元测试 - 我刚刚在单元测试文件 runit.stats.R 中查找了这一点,其中有很多针对这些统计“Rcpp 糖”的测试用例' 函数。

编辑于 2012 年 11 月 14 日: 随着今天发布的 Rcpp 0.10.0,您可以调用 do 签名 R::qnorm(double, double , double, int, int) 如果您想使用针对 Rmath.h 编写的 C 风格代码。 Rcpp Sugar 仍然为您提供矢量化版本。

关于r - 如何在 Rcpp 上使用 qnorm?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9738619/

相关文章:

r - 为什么悲伤的文字是积极的?

css - 由于另一个 div 而没有明显原因的 Div 偏移

c++ - RcppArmadillo:arma::cube 的 vector

r - 我们如何在 R 中的给定坐标处绘制图像?

r - 我可以使用 mi 包汇集估算的随机效应模型估计值吗?

html - 内联 block 与带图片的 block

android - 调试Kotlin内联函数

c++ - 将 DataFrame 转换为 Matrix 的最有效方法,反之亦然

c++ - Rcpp:如何将复数从 R 传递到 cpp

R - 创建显示两个相似数据集之间的增量/进度的数据集