cxxfunction error message, inline R-package

user3953420

I'm trying to reproduce an R example based in R help. This is an example for cxxfunction from inline package.

require(Rcpp)

require(inline)

# Rcpp plugin
if( require( Rcpp ) ){

fx <- cxxfunction( signature(x = "integer", y = "numeric" ) , '
    return wrap( as<int>(x) * as<double>(y) ) ;
', plugin = "Rcpp" )
fx( 2L, 5 )

    ## equivalent shorter form using rcpp()
fx <- rcpp(signature(x = "integer", y = "numeric"),
               ' return wrap( as<int>(x) * as<double>(y) ) ; ')

}

I got this message:

Error in compileCode(f, code, language = language, verbose = verbose) : Compilation ERROR, function(s)/method(s) not created! Warning message: running command 'make -f "C:/PROGRA~1/R/R-30~1.3/etc/i386/Makeconf" -f "C:/PROGRA~1/R/R-30~1.3/share/make/winshlib.mk" ....

And in addition:

Warning message: running command 'C:/PROGRA~1/R/R-30~1.3/bin/i386/R CMD SHLIB file3a86e316ef8.cpp ...

I'm using:

platform i386-w64-mingw32 and R-3.0.3

Rusan Kax

As Kevin said, its easier to use attributes. The attribute // [[Rcpp::export]] does all the work for you.

With the current versions on R and Rcpp installed create a file called test.cpp to put this code:

#include <Rcpp.h>
using namespace Rcpp;

// [[Rcpp::export]]
double fx(int x, double y){
    return x*y;
}


/*** R
fx(2L,5)
fx(2L,5.1)
*/

Then in a R session run: Rcpp::sourceCpp('test.cpp')

That should work, if you have followed the instructions for installing R, R-tools and set PATH variables (if on windows) correctly.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related