Re: [Rcpp-devel] Problem with NumericVector or NumericMatrix

2016-03-01 Thread Dirk Eddelbuettel
On 1 March 2016 at 10:29, Philippe Huber wrote: | Hi, | | I am starting to use Rcpp and got into some issues with basic examples. | | I am trying to run this: | | #include | | using namespace Rcpp; | | // [[Rcpp::export]] | NumericVector timesTwo(NumericVector x) { | return x * 2; | } | |

Re: [Rcpp-devel] Problem with NumericVector or NumericMatrix

2016-03-01 Thread Vaidas Zemlys
Hi, You do not need to use evalCpp. After you use Rcpp::sourceCpp, you can use timesTwo as a normal R function, i.e. you do not need evalCpp. This is quite clearly demonstrated in Rstudio template for C++ code. Vaidotas > Le 1 mars 2016 à 11:29, Philippe Huber a écrit : > > Hi, > > I am sta

[Rcpp-devel] Problem with NumericVector or NumericMatrix

2016-03-01 Thread Philippe Huber
Hi, I am starting to use Rcpp and got into some issues with basic examples. I am trying to run this: #include using namespace Rcpp; // [[Rcpp::export]]NumericVector timesTwo(NumericVector x) { return x * 2;} It works fine when I use it like:> evalCpp(timesTwo(2))[1] 4 But as soon as I use a vecto