For now I am using the following, which seems to work. I didn't really need
all the functionality from sample(); I just needed to get a random index
(but with non-uniform probabilities). It might be cleaner to use
std::accumulate in rcategorical, but I got this working first. Also,
rcategorical
On 14 May 2011 at 18:01, Chris DuBois wrote:
| Thanks Dirk. Passing the addition function in the includes argument worked
| great.
|
| Also, one of the links from your suggested Google search led me to this
| (working) example for std::accumulate:
|
| src <- 'NumericVector xx(x);
| return wra
Thanks Dirk. Passing the addition function in the includes argument worked
great.
Also, one of the links from your suggested Google search led me to this
(working) example for std::accumulate:
src <- 'NumericVector xx(x);
return wrap( std::accumulate( xx.begin(), xx.end(), 0.0));'
fx <- cxxfunct
On 14 May 2011 at 19:41, Christian Gunning wrote:
| > In the Rcpp vignettes, I found some of the R-like functions for
| > sampling from distributions (runif, rnorm, etc), but I didn't see a function
| > mimicking sample(). I checked the list of unit tests and didn't see it there
| > either. Have
> In the Rcpp vignettes, I found some of the R-like functions for
> sampling from distributions (runif, rnorm, etc), but I didn't see a function
> mimicking sample(). I checked the list of unit tests and didn't see it there
> either. Have I missed it? Is there a C++ function I should be using to
On 14 May 2011 at 17:13, Chris DuBois wrote:
| Thanks Dirk. Quick newbie followup question: Can we put functions within the
| inline C++ code? The following doesn't compile, for example:
| src <- '
| int addition (int a, int b)
| {
| int r;
| r=a+b;
| return (r);
| }
| NumericVector xx(x);
On 14 May 2011 at 16:33, Douglas Bates wrote:
| You can check what is done in R itself in the R sources but I imagine that it
| uses a uniform random variate converted to an integer through the cumulative
| probabilities. The good news is that it is easy to create the cumulative
| weights with the
Thanks Dirk. Quick newbie followup question: Can we put functions within
the inline C++ code? The following doesn't compile, for example:
src <- '
int addition (int a, int b)
{
int r;
r=a+b;
return (r);
}
NumericVector xx(x);
return(xx);
'
testfun = cxxfunction(signature(x="numeric"),body=s
Hi Michael,
On 14 May 2011 at 18:00, Michael Braun wrote:
| Hi, Rcpp-friends:
|
| File this post under "rookie mistake, "educational illustration," or "feature
request," but I noticed something in accessing elements from Rcpp matrices that
I found somewhat curious. Consider the following code
On 14 May 2011 at 23:12, Nick Sabbe wrote:
| I?ve been trying the following, with the main part ripped from rcpp-quickref:
|
| SEXP dfr2Mat(SEXP dfr)
A much easier way is to, say, call as.matrix() in R and then assign to an
NumericMatrix object in C++.
Another way is turn the Data.Frame i
Nick:
I had a similar problem a few weeks ago. The underscore is part of the Rcpp
namespace. So I added using namespace Rcpp at the beginning of my function,
and then all worked well. I can't tell from the compiler output if that is
*exactly* what the problem is, but it's worth taking a look
Hi, Rcpp-friends:
File this post under "rookie mistake, "educational illustration," or "feature
request," but I noticed something in accessing elements from Rcpp matrices that
I found somewhat curious. Consider the following code, for which the objective
is just to print elements of a matrix.
On 14 May 2011 at 14:11, Chris DuBois wrote:
| I'm just getting my feet wet with some Rcpp. I'm comfortable with R but new
| to C++. In the Rcpp vignettes, I found some of the R-like functions for
| sampling from distributions (runif, rnorm, etc), but I didn't see a function
| mimicking sample()
You can check what is done in R itself in the R sources but I imagine that
it uses a uniform random variate converted to an integer through the
cumulative probabilities. The good news is that it is easy to create the
cumulative weights with the std::accumulate function.
On May 14, 2011 4:12 PM, "Ch
Hi all,
I've been trying the following, with the main part ripped from
rcpp-quickref:
SEXP dfr2Mat(SEXP dfr)
{
DataFrame df = dfr;
int* dm = INTEGER( ::Rf_getAttrib( df, R_DimSymbol ) ) ;
int rows = dm[0];
int cols = dm[1];
NumericMatrix re
Hi all,
I'm just getting my feet wet with some Rcpp. I'm comfortable with R but new
to C++. In the Rcpp vignettes, I found some of the R-like functions for
sampling from distributions (runif, rnorm, etc), but I didn't see a function
mimicking sample(). I checked the list of unit tests and didn't
Soeren,
On 13 May 2011 at 20:07, soeren.vo...@uzh.ch wrote:
| Compilation with R CMD CHECK FOO fails with the following error in
00install.out:
|
| Error in dyn.load(file, DLLpath = DLLpath, ...) :
| unable to load shared object
'/Users/sovo/GUTS/FOO.Rcheck/FOO/libs/i386/FOO.so':
| dlopen
Excellent, thanks for the update.
Jelmer
On Sat, May 14, 2011 at 17:20, Dirk Eddelbuettel wrote:
>
> On 13 May 2011 at 11:58, Dirk Eddelbuettel wrote:
> | On 13 May 2011 at 16:35, Jelmer Ypma wrote:
> | | Dear Rcpp-list,
> | |
> | | I'm trying to expose multiple constructors of a C++ class to R
On 13 May 2011 at 11:58, Dirk Eddelbuettel wrote:
| On 13 May 2011 at 16:35, Jelmer Ypma wrote:
| | Dear Rcpp-list,
| |
| | I'm trying to expose multiple constructors of a C++ class to R using
| | modules. Here is an example of what I want to do based on the Uniform
| | example
[...]
| | Compil
19 matches
Mail list logo