[Rcpp-devel] pnorm/qnorm?

Dirk Eddelbuettel edd at debian.org
Mon Sep 10 17:35:03 CEST 2012


On 10 September 2012 at 10:23, Rodney Sparapani wrote:
| On 09/07/2012 12:19 PM, Dirk Eddelbuettel wrote:
| > Make that   Rcpp::NumericVector a = Rcpp::NumericVector(arg1);  and things
| > will just work.
| >
| > Would be nice if the compiler messahes could be more helpful...   All sugar
| > functions are vectorised, so you must feed them a vector (which, as we work
| > with R, may well be of length 1 if you so choose....)
| >
| > Dirk
| 
| Thank you Dirk!  But, I seem to keep messing this up.  Could you take a 
| look at this?

Please look at the two emails I sent in this thread on Sep 7. 

Dirk

| 
| require(Rcpp)
| require(inline)
| 
| str <- '
| double x=as<double>(qnorm(as<NumericVector>(arg1), 
| as<NumericVector>(arg2), as<NumericVector>(1.))[0]);
| return wrap(x);
| '
| 
| check2 <- cxxfunction(signature(arg1="numeric", arg2="numeric"), str, 
| plugin="Rcpp")
| 
| check2(0.5, 0.5)
| 
| ...
| 
|   31: double x=as<double>(qnorm(as<NumericVector>(arg1), 
| as<NumericVector>(arg2), as<NumericVector>(1.))[0]);
|   32: return wrap(x);
|   33:
|   34: END_RCPP
|   35: }
|   36:
|   37:
| Error in compileCode(f, code, language = language, verbose = verbose) :
|    Compilation ERROR, function(s)/method(s) not created! 
| file1a785d3ff187.cpp: In function 'SEXPREC* file1a785d3ff187(SEXPREC*, 
| SEXPREC*)':
| file1a785d3ff187.cpp:31: error: no matching function for call to 
| 'as(double)'
| make: *** [file1a785d3ff187.o] Error 1
| In addition: Warning message:
| running command '/opt/local/lib64/R/bin/R CMD SHLIB file1a785d3ff187.cpp 
| 2> file1a785d3ff187.cpp.err.txt' had status 1
| 
| -- 
| Rodney Sparapani, PhD  Center for Patient Care and Outcomes Research
| Sr. Biostatistician               http://www.mcw.edu/pcor
| 4 wheels good, 2 wheels better!   Medical College of Wisconsin (MCW)
| WWLD?:  What Would Lombardi Do?   Milwaukee, WI, USA

-- 
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com  


More information about the Rcpp-devel mailing list