Yes, that's exactly what I was looking for. Although I'd return an integer:
// [[Rcpp::export]] IntegerVector foo_int() { Function opt("getOption"); IntegerVector x = opt("digits"); return x; } On Sat, Aug 1, 2015 at 5:15 PM, Søren Højsgaard <sor...@math.aau.dk> wrote: > Something like > > > > #include <Rcpp.h> > > using namespace Rcpp; > > > > // [[Rcpp::export]] > > CharacterVector foo() { > > Function opt("getOption"); > > CharacterVector x = opt("digits"); > > return x; > > } > > > > /*** R > > foo() > > */ > > > > > foo() > > [1] "7" > > > > - all though the result is here a character. > > > > Regards > > Søren > > > > > > *From:* rcpp-devel-boun...@lists.r-forge.r-project.org [mailto: > rcpp-devel-boun...@lists.r-forge.r-project.org] *On Behalf Of *Rguy > *Sent:* 1. august 2015 08:07 > *To:* Rcpp > *Subject:* [Rcpp-devel] Getting an R option in Rcpp > > > > Can I access an R option from within an Rcpp function? I'd like the access > to happen at runtime, not at compile time. Something like this: > > > > if (getOption("my_option") == x) { > > do this; > > } else { > > do that; > > } > > > > >
_______________________________________________ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel