Is there a way to do rep(NA_real_, times = 5) in Rcpp? I want to later replace NA_real_ with numbers in a for-loop #rstats
1
2
Better to ask on the #rcpp-devel list than here but here you go:
> Rcpp::cppFunction("NumericVector myrep(double val, int n) { return rep(val, n); }")
> myrep(NA_real_, 3)
[1] NA NA NA
> myrep(3.14, 2)
[1] 3.14 3.14
>
Hint: Search among unit tests.
Apr 8, 2021 · 11:57 PM UTC
1
3

