Do you want Rf_isNull :
SEXP dm = inp.attr("dimnames"); if (!Rf_isNull(dm) && Rf_length(dm) > 1) { out.attr("names") = VECTOR_ELT(dm, 1); }
FWIW, due to this awkwardness, we are likely to add rownames , colnames to Rcpp in the future.
(Checking the length is just to make sure there is something to find in index 1 the dimnames attribute)
source share