The parsing of default values for attributes has some significant limitations (it's mostly just use for literals and empty vectors). This is what is currently supported:
• String literals delimited by quotes (e.g. "foo") • Decimal numeric values (e.g. 10 or 4.5) • Pre-defined constants including true, false, R_NilValue, NA_STRING, NA_INTEGER, NA_REAL, and NA_LOGICAL. • Selected vector types (CharacterVector, IntegerVector, and NumericVector) instantiated using the empty form of the ::create static member function. • Matrix types instantiated using the rows, cols constructor. On Wed, Jan 13, 2016 at 10:41 AM, Lafaye de Micheaux Pierre <laf...@dms.umontreal.ca> wrote: > 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 > > _______________________________________________ > Rcpp-devel mailing list > Rcpp-devel@lists.r-forge.r-project.org > https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel _______________________________________________ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel