[Rcpp-devel] How to give default value with Rcpp and roxygen2 involving seq_len
Lafaye de Micheaux Pierre
lafaye at dms.umontreal.ca
Wed Jan 13 16:41:13 CET 2016
Hello everybody,
Let's consider the simple function:
f <- function(x = 1:10) {return(x)}
where the argument 'x' could take non integer values.
I would like to create such a function using Rcpp and roxygen2. If I try
something like:
//' @param x Vector of real values
NumericVector f(NumericVector x) {return(x);}
then after creation using devtools, I will obtain a function like this
one:
f <- function(x) {return(x)}
How can I write things in my C++ code so that I will obtain
the x = 1:10 default values?
I tried something like:
//' @param x Vector of real values
NumericVector f(NumericVector x = NumericVector::create(seq_len(10))
{return(x);}
but it failed completely ...
I am quite new to Rcpp, so I apologize if my question is too naive. If
this is the case, feel free to send me a web link to some documentation
that I could learn to try to solve this problem by myself.
Best regards,
Pierre
More information about the Rcpp-devel
mailing list