Closed DavisVaughan closed 5 years ago
I'm also not sure it works right with matrices. It seems to print right for vectors, but with matrices it doesn't print the N/A
. However, it does compute the right value.
Rcpp::sourceCpp("~/Desktop/test.cpp")
vec <- c(1L, 2L, 3L, 4L, NA_integer_, 6L)
mat <- matrix(vec, ncol = 1)
trash <- sum_print_optional_int(vec)
# { 1, 2, 3, 4, N/A, 6}
# N/A
trash <- sum_print_optional_int(mat)
# {{ 1},
# { 2},
# { 3},
# { 4},
# {-2147483648},
# { 6}}
# N/A
Indeed, I think that we need a operator SEXP()
which would return SEXP(m_value)
in rcontainer_optional
.
I'm having a bit of trouble working with the optional support. Mainly, I can't get the result back out into something to convert to R. It looks like the optional support is working, I just can't get the result out.
1) Below,
sum_print_optional_int()
shows that things are working right.2) The commented out version of
sum_print_optional_int()
shows that I have to useauto
as the result of thesum(<rarray_optional>)
operation. Is this right? I can't coerce directly to anotherrarray_optional
?3)
sum_optional_int()
is me attempting to get the results of thesum()
into something I can return to R. But I don't know how.As you can see here, the
NA
are propagating correctly: