[Rcpp-devel] Call by reference

2015-07-28 Thread Rguy
I attempted to implement the call by reference example on page 200 of Seamless R and C++, as follows: #include using namespace Rcpp; // [[Rcpp::export]] void absC(double & x) { if (x < 0) x = -x; } /*** R x = -1 absC(x) x */ Unfortunately, x remains equal to -1. Platforms: Windows 7, "R versi

Re: [Rcpp-devel] Call by reference

2015-07-28 Thread Rguy
mericVector is > expected; hence a copying takes place. > > Regards > Søren > > > > > |-Original Message- > |From: rcpp-devel-boun...@lists.r-forge.r-project.org [mailto:rcpp-devel- > |boun...@lists.r-forge.r-project.org] On Behalf Of Dirk Eddelbuettel > |

Re: [Rcpp-devel] Call by reference

2015-07-29 Thread Rguy
, which is why I am interested in utilizing C++, which supports call by reference. On Wed, Jul 29, 2015 at 12:37 PM, Dirk Eddelbuettel wrote: > > On 29 July 2015 at 07:29, Rguy wrote: > | Thanks for the insight. For other readers possibly struggling with call > by > | reference, the

[Rcpp-devel] Getting an R option in Rcpp

2015-07-31 Thread Rguy
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-

Re: [Rcpp-devel] Getting an R option in Rcpp

2015-08-01 Thread Rguy
} > > > > /*** 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.or

[Rcpp-devel] NA in templates

2015-09-08 Thread Rguy
What is correct way to represent NA in a template? I have been successfully using NA_REAL (see example below) but I am not sure if this is the proper method. Thanks. /* template_NA.cpp: Experiment with use of NA in templates in Rcpp. Change first member of a vector to NA. */ #include using names

[Rcpp-devel] T::get_na() where T is a Column

2015-09-11 Thread Rguy
I would like to call a template function including the expression T::get_na() with a matrix Column as the T. The toy program below illustrates what I am trying to do. Various error messages are generated by the compiler with, I think, the key one being: column_get_na.cpp:11:2: error: 'get_na' is

[Rcpp-devel] clusterExport fails on Rcpp functions

2015-09-11 Thread Rguy
I find that when I attempt to export Rcpp functions to a cluster using the R clusterExport function I get the following error (or some variant thereof): Error in checkForRemoteErrors(val) : 5 nodes produced errors; first error: NULL value passed as symbol address I am running Windows 7, and the

[Rcpp-devel] DataFrame names

2015-09-18 Thread Rguy
In reading the names of a data frame in an Rcpp program I find that the following both work: CharacterVector nmz = dfr.names(); CharacterVector nmz = dfr.attr("names"); Is there any reason to prefer one to the other, or are they considered equivalent? _