Skip to content
Prev 7213 / 10988 Next

[Rcpp-devel] Default empty values for vector and matrices

Le 17 f?vr. 2014 ? 12:17, Alessandro Mammana <mammana at molgen.mpg.de> a ?crit :
R?s behavior is incoherent. NULL is not a numeric vector.
That?s the attribute parser not making sense of it. It does compile, but the default is not propagated to R.
Well. It might appear as something that works. It is in fact a bug. NumericVector::create(0) is supposed to create a vector of length 1 with the value of the first element set to 0. not numeric vector of length zero as it is currently the case. bug. 
https://github.com/RcppCore/Rcpp/issues/117
Matrix::create is nonsense as it does not create a matrix. check :
num 0

so creates a vector, not a matrix. Besides, what do you actually expect. What dimensions would this matrix have ?
My suggestion would be to handle this on the R side. The attribute parser is not a fully capable C++ parser, stick to defaults for only very simple things, like int or double or strings. 

For anything else, you?re better of with dealing with the parameter logic on the R side.