[Rcpp-devel] IntegerVector initialization

Gregor Kastner mailinglist at gmx.at
Fri Jan 13 00:28:46 CET 2012


> | This is a minor thing but caused some confusion to me:
> | 
> | IntegerVector foo1(2, 4.0);  // works
> | IntegerVector foo2(2, 4);    // throws error
> 
> What were you expecting with the second argument?  A 'fill' value?
> Arguably, int should then work.

Yes, inspired by

// ... with a default for all values
NumericVector xx(10, 2.0);

on page 1 of Rcpp-quickref's "Create simple vectors" box.

> | while
> | 
> | IntegerVector bar1 = IntegerVector::create(4.0, 4.0);  // works
> | IntegerVector bar2 = IntegerVector::create(4, 4);      // works
> 
> ::create is very different from the constructors above.

Sure, but in this case I get the same results: "c(4L,4L)", right?

Best,
/g


More information about the Rcpp-devel mailing list