Rcpp: cannot access module class inside R code of the same package










1















Let's say I want to build a very simple package in R that wraps c++ code.

My test project would be called bananas.



Let's say I have a folder called "bananas", where inside I have two other folders one called c++ and one called R.



Inside the c++ folder I have folder called include that contains the bananas.hpp header file (with the class definition):



#ifndef BANANAS_H
#define BANANAS_H

class Bananas

public:
void add_banana();
int get_bananas();

protected:
int number_of_bananas;
;

#endif


Outside include there is the bananas.cpp file that implements the methods of bananas.hpp:



#include "include/bananas.hpp"
using namespace std;

void Bananas::add_banana()
// Return False if edge already existed
number_of_bananas ++;


int Bananas::get_bananas()
return number_of_bananas;



now in my R folder I have a the wrapper.cpp file that uses Rcpp library to export c++ classes inside R as a module:



#include <Rcpp.h>
#include "include/bananas.hpp"

using namespace Rcpp;

RCPP_EXPOSED_CLASS(Bananas)

RCPP_MODULE(Bananas_cpp)

class_<Bananas>("BananasCPP")
.default_constructor()
.method("add_banana", &Bananas::add_banana)
.method("get_bananas", &Bananas::get_bananas)
;



Note that right now #include "include/bananas.hpp" does not mean anything, but in the future this file will be added inside source.
Finally I have my main concern which a R wrapper of this class under:



require(R6)
library(Rcpp)

# For exposing the error
print(ls(all.names = TRUE))

# Load Module
bcpp <- Module("Bananas_cpp", PACKAGE="RBananasC", mustStart = TRUE)$BananasCPP

Bananas <- R6Class("Bananas", list(
bn = new(bcpp),
print_bananas = function() print(self$bn$get_bananas()),
banana_tree = function(d)
for(row in 1:d)
self$bn$add_banana()


))


Now when running the setup.R file in my main directory which looks as follows:



require(Rcpp)

# Make a base package
unlink("RBananasC", recursive=TRUE)
Rcpp.package.skeleton(name = "RBananasC", list = character(),
path = ".", force = FALSE,
cpp_files = c("bananas/R/wrapper.cpp", "bananas/c++/bananas.cpp", "bananas/c++/include/bananas.hpp"))
dir.create("RBananasC/src/include")
file.rename("RBananasC/src/bananas.hpp", "RBananasC/src/include/bananas.hpp")
install.packages("RBananasC", repos=NULL, type="source")

# See that Bananas_cpp works
library(RBananasC) #Without this line it doesn't work

print(Module("Bananas_cpp", PACKAGE="RBananasC", mustStart = TRUE)$BananasCPP)
bcpp <- Module("Bananas_cpp", PACKAGE="RBananasC", mustStart = TRUE)$BananasCPP
ban <- new(bcpp)
ban$add_banana()
print(ban$get_bananas())

# Make the desired package
unlink("RBananas", recursive=TRUE)
Rcpp.package.skeleton(name = "RBananas", list = character(),
path = ".", force = FALSE,
code_files = c("bananas/R/bananas.R"), cpp_files = c("bananas/R/wrapper.cpp", "bananas/c++/bananas.cpp", "bananas/c++/include/bananas.hpp"))
dir.create("RBananas/src/include")
file.rename("RBananas/src/bananas.hpp", "RBananas/src/include/bananas.hpp")
install.packages("RBananas", repos=NULL, type="source")


I have a very strange behaviour inside my bananas.R file, that has to do with the fact that Bananas_cpp module of my package is not visible and so I cannot access the class BananasCPP upon installation.
On the other hand if I ignore the file bananas.R I can import the BananasCPP from the module Bananas_cpp of the package RBananasC, I created using Rcpp.package.skeleton.



To sum up the total file structure looks like:



.
├── bananas
│   ├── c++
│   │   ├── bananas.cpp
│   │   └── include
│   │   └── bananas.hpp
│   └── R
│   ├── bananas.R
│   └── wrapper.cpp
└── setup.R


And to demonstrate what is my problem you just run the setup.R.



I followed a standard tutorial, but I couldn't find any information of how I can load my BananasCPP class from the Bananas_cpp module inside my Bananas.R wrap function Bananas, while searching for days in the internet. This file does not appear in the namespace of the environment active inside the package, so I think this what should be tackled: "which commands I should add and where to expose my Bananas_cpp module inside the current namespace of the package".



Of course this is a reproducible that I made from a real problem I had.
Thanks a lot for your support!










share|improve this question

















  • 3





    This is too long for me to study in detail but the top-level question is: why are you reinventing package layout when existing packages with modules exist and you could just copy that structure?

    – Dirk Eddelbuettel
    Nov 15 '18 at 16:31











  • Dirk is right. You should make a package. For a course, I've made a quick tuto to make a package (including Rcpp and some includes in inst/) here.

    – F. Privé
    Nov 15 '18 at 19:49











  • The top level question is: "'which' commands should I add and 'where', in order expose an Rcpp module containing a class inside the current namespace of the package, for the execution of a R file of the same package upon installation". My problem is that the R file cannot see the Rcpp module that is produced and compiled successfully inside the package, when installed. I used the Rcpp skeleton in order to demonstrate this error with the basic package Rcpp skeleton (when everything is declared appropriately), which should work with such a basic example (except if I forgot to declare something).

    – John Sig
    Nov 16 '18 at 14:43












  • The skeleton generator used to have a 'create with Modules' mode, but we took that out. For a minimal package, look at one included with our unit tests; for (larger) real life ones my RcppRedis and RcppCNPy and RcppAnnoy packages may suit (but they may also distract you as they need more stuff). I'd start with the minimal one.

    – Dirk Eddelbuettel
    Nov 16 '18 at 21:41











  • I have followed this basic example but it doesn't say anything about classes. Propably what I want is the similar command for loading a class instead of a function.

    – John Sig
    Nov 20 '18 at 17:42
















1















Let's say I want to build a very simple package in R that wraps c++ code.

My test project would be called bananas.



Let's say I have a folder called "bananas", where inside I have two other folders one called c++ and one called R.



Inside the c++ folder I have folder called include that contains the bananas.hpp header file (with the class definition):



#ifndef BANANAS_H
#define BANANAS_H

class Bananas

public:
void add_banana();
int get_bananas();

protected:
int number_of_bananas;
;

#endif


Outside include there is the bananas.cpp file that implements the methods of bananas.hpp:



#include "include/bananas.hpp"
using namespace std;

void Bananas::add_banana()
// Return False if edge already existed
number_of_bananas ++;


int Bananas::get_bananas()
return number_of_bananas;



now in my R folder I have a the wrapper.cpp file that uses Rcpp library to export c++ classes inside R as a module:



#include <Rcpp.h>
#include "include/bananas.hpp"

using namespace Rcpp;

RCPP_EXPOSED_CLASS(Bananas)

RCPP_MODULE(Bananas_cpp)

class_<Bananas>("BananasCPP")
.default_constructor()
.method("add_banana", &Bananas::add_banana)
.method("get_bananas", &Bananas::get_bananas)
;



Note that right now #include "include/bananas.hpp" does not mean anything, but in the future this file will be added inside source.
Finally I have my main concern which a R wrapper of this class under:



require(R6)
library(Rcpp)

# For exposing the error
print(ls(all.names = TRUE))

# Load Module
bcpp <- Module("Bananas_cpp", PACKAGE="RBananasC", mustStart = TRUE)$BananasCPP

Bananas <- R6Class("Bananas", list(
bn = new(bcpp),
print_bananas = function() print(self$bn$get_bananas()),
banana_tree = function(d)
for(row in 1:d)
self$bn$add_banana()


))


Now when running the setup.R file in my main directory which looks as follows:



require(Rcpp)

# Make a base package
unlink("RBananasC", recursive=TRUE)
Rcpp.package.skeleton(name = "RBananasC", list = character(),
path = ".", force = FALSE,
cpp_files = c("bananas/R/wrapper.cpp", "bananas/c++/bananas.cpp", "bananas/c++/include/bananas.hpp"))
dir.create("RBananasC/src/include")
file.rename("RBananasC/src/bananas.hpp", "RBananasC/src/include/bananas.hpp")
install.packages("RBananasC", repos=NULL, type="source")

# See that Bananas_cpp works
library(RBananasC) #Without this line it doesn't work

print(Module("Bananas_cpp", PACKAGE="RBananasC", mustStart = TRUE)$BananasCPP)
bcpp <- Module("Bananas_cpp", PACKAGE="RBananasC", mustStart = TRUE)$BananasCPP
ban <- new(bcpp)
ban$add_banana()
print(ban$get_bananas())

# Make the desired package
unlink("RBananas", recursive=TRUE)
Rcpp.package.skeleton(name = "RBananas", list = character(),
path = ".", force = FALSE,
code_files = c("bananas/R/bananas.R"), cpp_files = c("bananas/R/wrapper.cpp", "bananas/c++/bananas.cpp", "bananas/c++/include/bananas.hpp"))
dir.create("RBananas/src/include")
file.rename("RBananas/src/bananas.hpp", "RBananas/src/include/bananas.hpp")
install.packages("RBananas", repos=NULL, type="source")


I have a very strange behaviour inside my bananas.R file, that has to do with the fact that Bananas_cpp module of my package is not visible and so I cannot access the class BananasCPP upon installation.
On the other hand if I ignore the file bananas.R I can import the BananasCPP from the module Bananas_cpp of the package RBananasC, I created using Rcpp.package.skeleton.



To sum up the total file structure looks like:



.
├── bananas
│   ├── c++
│   │   ├── bananas.cpp
│   │   └── include
│   │   └── bananas.hpp
│   └── R
│   ├── bananas.R
│   └── wrapper.cpp
└── setup.R


And to demonstrate what is my problem you just run the setup.R.



I followed a standard tutorial, but I couldn't find any information of how I can load my BananasCPP class from the Bananas_cpp module inside my Bananas.R wrap function Bananas, while searching for days in the internet. This file does not appear in the namespace of the environment active inside the package, so I think this what should be tackled: "which commands I should add and where to expose my Bananas_cpp module inside the current namespace of the package".



Of course this is a reproducible that I made from a real problem I had.
Thanks a lot for your support!










share|improve this question

















  • 3





    This is too long for me to study in detail but the top-level question is: why are you reinventing package layout when existing packages with modules exist and you could just copy that structure?

    – Dirk Eddelbuettel
    Nov 15 '18 at 16:31











  • Dirk is right. You should make a package. For a course, I've made a quick tuto to make a package (including Rcpp and some includes in inst/) here.

    – F. Privé
    Nov 15 '18 at 19:49











  • The top level question is: "'which' commands should I add and 'where', in order expose an Rcpp module containing a class inside the current namespace of the package, for the execution of a R file of the same package upon installation". My problem is that the R file cannot see the Rcpp module that is produced and compiled successfully inside the package, when installed. I used the Rcpp skeleton in order to demonstrate this error with the basic package Rcpp skeleton (when everything is declared appropriately), which should work with such a basic example (except if I forgot to declare something).

    – John Sig
    Nov 16 '18 at 14:43












  • The skeleton generator used to have a 'create with Modules' mode, but we took that out. For a minimal package, look at one included with our unit tests; for (larger) real life ones my RcppRedis and RcppCNPy and RcppAnnoy packages may suit (but they may also distract you as they need more stuff). I'd start with the minimal one.

    – Dirk Eddelbuettel
    Nov 16 '18 at 21:41











  • I have followed this basic example but it doesn't say anything about classes. Propably what I want is the similar command for loading a class instead of a function.

    – John Sig
    Nov 20 '18 at 17:42














1












1








1








Let's say I want to build a very simple package in R that wraps c++ code.

My test project would be called bananas.



Let's say I have a folder called "bananas", where inside I have two other folders one called c++ and one called R.



Inside the c++ folder I have folder called include that contains the bananas.hpp header file (with the class definition):



#ifndef BANANAS_H
#define BANANAS_H

class Bananas

public:
void add_banana();
int get_bananas();

protected:
int number_of_bananas;
;

#endif


Outside include there is the bananas.cpp file that implements the methods of bananas.hpp:



#include "include/bananas.hpp"
using namespace std;

void Bananas::add_banana()
// Return False if edge already existed
number_of_bananas ++;


int Bananas::get_bananas()
return number_of_bananas;



now in my R folder I have a the wrapper.cpp file that uses Rcpp library to export c++ classes inside R as a module:



#include <Rcpp.h>
#include "include/bananas.hpp"

using namespace Rcpp;

RCPP_EXPOSED_CLASS(Bananas)

RCPP_MODULE(Bananas_cpp)

class_<Bananas>("BananasCPP")
.default_constructor()
.method("add_banana", &Bananas::add_banana)
.method("get_bananas", &Bananas::get_bananas)
;



Note that right now #include "include/bananas.hpp" does not mean anything, but in the future this file will be added inside source.
Finally I have my main concern which a R wrapper of this class under:



require(R6)
library(Rcpp)

# For exposing the error
print(ls(all.names = TRUE))

# Load Module
bcpp <- Module("Bananas_cpp", PACKAGE="RBananasC", mustStart = TRUE)$BananasCPP

Bananas <- R6Class("Bananas", list(
bn = new(bcpp),
print_bananas = function() print(self$bn$get_bananas()),
banana_tree = function(d)
for(row in 1:d)
self$bn$add_banana()


))


Now when running the setup.R file in my main directory which looks as follows:



require(Rcpp)

# Make a base package
unlink("RBananasC", recursive=TRUE)
Rcpp.package.skeleton(name = "RBananasC", list = character(),
path = ".", force = FALSE,
cpp_files = c("bananas/R/wrapper.cpp", "bananas/c++/bananas.cpp", "bananas/c++/include/bananas.hpp"))
dir.create("RBananasC/src/include")
file.rename("RBananasC/src/bananas.hpp", "RBananasC/src/include/bananas.hpp")
install.packages("RBananasC", repos=NULL, type="source")

# See that Bananas_cpp works
library(RBananasC) #Without this line it doesn't work

print(Module("Bananas_cpp", PACKAGE="RBananasC", mustStart = TRUE)$BananasCPP)
bcpp <- Module("Bananas_cpp", PACKAGE="RBananasC", mustStart = TRUE)$BananasCPP
ban <- new(bcpp)
ban$add_banana()
print(ban$get_bananas())

# Make the desired package
unlink("RBananas", recursive=TRUE)
Rcpp.package.skeleton(name = "RBananas", list = character(),
path = ".", force = FALSE,
code_files = c("bananas/R/bananas.R"), cpp_files = c("bananas/R/wrapper.cpp", "bananas/c++/bananas.cpp", "bananas/c++/include/bananas.hpp"))
dir.create("RBananas/src/include")
file.rename("RBananas/src/bananas.hpp", "RBananas/src/include/bananas.hpp")
install.packages("RBananas", repos=NULL, type="source")


I have a very strange behaviour inside my bananas.R file, that has to do with the fact that Bananas_cpp module of my package is not visible and so I cannot access the class BananasCPP upon installation.
On the other hand if I ignore the file bananas.R I can import the BananasCPP from the module Bananas_cpp of the package RBananasC, I created using Rcpp.package.skeleton.



To sum up the total file structure looks like:



.
├── bananas
│   ├── c++
│   │   ├── bananas.cpp
│   │   └── include
│   │   └── bananas.hpp
│   └── R
│   ├── bananas.R
│   └── wrapper.cpp
└── setup.R


And to demonstrate what is my problem you just run the setup.R.



I followed a standard tutorial, but I couldn't find any information of how I can load my BananasCPP class from the Bananas_cpp module inside my Bananas.R wrap function Bananas, while searching for days in the internet. This file does not appear in the namespace of the environment active inside the package, so I think this what should be tackled: "which commands I should add and where to expose my Bananas_cpp module inside the current namespace of the package".



Of course this is a reproducible that I made from a real problem I had.
Thanks a lot for your support!










share|improve this question














Let's say I want to build a very simple package in R that wraps c++ code.

My test project would be called bananas.



Let's say I have a folder called "bananas", where inside I have two other folders one called c++ and one called R.



Inside the c++ folder I have folder called include that contains the bananas.hpp header file (with the class definition):



#ifndef BANANAS_H
#define BANANAS_H

class Bananas

public:
void add_banana();
int get_bananas();

protected:
int number_of_bananas;
;

#endif


Outside include there is the bananas.cpp file that implements the methods of bananas.hpp:



#include "include/bananas.hpp"
using namespace std;

void Bananas::add_banana()
// Return False if edge already existed
number_of_bananas ++;


int Bananas::get_bananas()
return number_of_bananas;



now in my R folder I have a the wrapper.cpp file that uses Rcpp library to export c++ classes inside R as a module:



#include <Rcpp.h>
#include "include/bananas.hpp"

using namespace Rcpp;

RCPP_EXPOSED_CLASS(Bananas)

RCPP_MODULE(Bananas_cpp)

class_<Bananas>("BananasCPP")
.default_constructor()
.method("add_banana", &Bananas::add_banana)
.method("get_bananas", &Bananas::get_bananas)
;



Note that right now #include "include/bananas.hpp" does not mean anything, but in the future this file will be added inside source.
Finally I have my main concern which a R wrapper of this class under:



require(R6)
library(Rcpp)

# For exposing the error
print(ls(all.names = TRUE))

# Load Module
bcpp <- Module("Bananas_cpp", PACKAGE="RBananasC", mustStart = TRUE)$BananasCPP

Bananas <- R6Class("Bananas", list(
bn = new(bcpp),
print_bananas = function() print(self$bn$get_bananas()),
banana_tree = function(d)
for(row in 1:d)
self$bn$add_banana()


))


Now when running the setup.R file in my main directory which looks as follows:



require(Rcpp)

# Make a base package
unlink("RBananasC", recursive=TRUE)
Rcpp.package.skeleton(name = "RBananasC", list = character(),
path = ".", force = FALSE,
cpp_files = c("bananas/R/wrapper.cpp", "bananas/c++/bananas.cpp", "bananas/c++/include/bananas.hpp"))
dir.create("RBananasC/src/include")
file.rename("RBananasC/src/bananas.hpp", "RBananasC/src/include/bananas.hpp")
install.packages("RBananasC", repos=NULL, type="source")

# See that Bananas_cpp works
library(RBananasC) #Without this line it doesn't work

print(Module("Bananas_cpp", PACKAGE="RBananasC", mustStart = TRUE)$BananasCPP)
bcpp <- Module("Bananas_cpp", PACKAGE="RBananasC", mustStart = TRUE)$BananasCPP
ban <- new(bcpp)
ban$add_banana()
print(ban$get_bananas())

# Make the desired package
unlink("RBananas", recursive=TRUE)
Rcpp.package.skeleton(name = "RBananas", list = character(),
path = ".", force = FALSE,
code_files = c("bananas/R/bananas.R"), cpp_files = c("bananas/R/wrapper.cpp", "bananas/c++/bananas.cpp", "bananas/c++/include/bananas.hpp"))
dir.create("RBananas/src/include")
file.rename("RBananas/src/bananas.hpp", "RBananas/src/include/bananas.hpp")
install.packages("RBananas", repos=NULL, type="source")


I have a very strange behaviour inside my bananas.R file, that has to do with the fact that Bananas_cpp module of my package is not visible and so I cannot access the class BananasCPP upon installation.
On the other hand if I ignore the file bananas.R I can import the BananasCPP from the module Bananas_cpp of the package RBananasC, I created using Rcpp.package.skeleton.



To sum up the total file structure looks like:



.
├── bananas
│   ├── c++
│   │   ├── bananas.cpp
│   │   └── include
│   │   └── bananas.hpp
│   └── R
│   ├── bananas.R
│   └── wrapper.cpp
└── setup.R


And to demonstrate what is my problem you just run the setup.R.



I followed a standard tutorial, but I couldn't find any information of how I can load my BananasCPP class from the Bananas_cpp module inside my Bananas.R wrap function Bananas, while searching for days in the internet. This file does not appear in the namespace of the environment active inside the package, so I think this what should be tackled: "which commands I should add and where to expose my Bananas_cpp module inside the current namespace of the package".



Of course this is a reproducible that I made from a real problem I had.
Thanks a lot for your support!







c++ r rcpp






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 15 '18 at 16:12









John SigJohn Sig

849




849







  • 3





    This is too long for me to study in detail but the top-level question is: why are you reinventing package layout when existing packages with modules exist and you could just copy that structure?

    – Dirk Eddelbuettel
    Nov 15 '18 at 16:31











  • Dirk is right. You should make a package. For a course, I've made a quick tuto to make a package (including Rcpp and some includes in inst/) here.

    – F. Privé
    Nov 15 '18 at 19:49











  • The top level question is: "'which' commands should I add and 'where', in order expose an Rcpp module containing a class inside the current namespace of the package, for the execution of a R file of the same package upon installation". My problem is that the R file cannot see the Rcpp module that is produced and compiled successfully inside the package, when installed. I used the Rcpp skeleton in order to demonstrate this error with the basic package Rcpp skeleton (when everything is declared appropriately), which should work with such a basic example (except if I forgot to declare something).

    – John Sig
    Nov 16 '18 at 14:43












  • The skeleton generator used to have a 'create with Modules' mode, but we took that out. For a minimal package, look at one included with our unit tests; for (larger) real life ones my RcppRedis and RcppCNPy and RcppAnnoy packages may suit (but they may also distract you as they need more stuff). I'd start with the minimal one.

    – Dirk Eddelbuettel
    Nov 16 '18 at 21:41











  • I have followed this basic example but it doesn't say anything about classes. Propably what I want is the similar command for loading a class instead of a function.

    – John Sig
    Nov 20 '18 at 17:42













  • 3





    This is too long for me to study in detail but the top-level question is: why are you reinventing package layout when existing packages with modules exist and you could just copy that structure?

    – Dirk Eddelbuettel
    Nov 15 '18 at 16:31











  • Dirk is right. You should make a package. For a course, I've made a quick tuto to make a package (including Rcpp and some includes in inst/) here.

    – F. Privé
    Nov 15 '18 at 19:49











  • The top level question is: "'which' commands should I add and 'where', in order expose an Rcpp module containing a class inside the current namespace of the package, for the execution of a R file of the same package upon installation". My problem is that the R file cannot see the Rcpp module that is produced and compiled successfully inside the package, when installed. I used the Rcpp skeleton in order to demonstrate this error with the basic package Rcpp skeleton (when everything is declared appropriately), which should work with such a basic example (except if I forgot to declare something).

    – John Sig
    Nov 16 '18 at 14:43












  • The skeleton generator used to have a 'create with Modules' mode, but we took that out. For a minimal package, look at one included with our unit tests; for (larger) real life ones my RcppRedis and RcppCNPy and RcppAnnoy packages may suit (but they may also distract you as they need more stuff). I'd start with the minimal one.

    – Dirk Eddelbuettel
    Nov 16 '18 at 21:41











  • I have followed this basic example but it doesn't say anything about classes. Propably what I want is the similar command for loading a class instead of a function.

    – John Sig
    Nov 20 '18 at 17:42








3




3





This is too long for me to study in detail but the top-level question is: why are you reinventing package layout when existing packages with modules exist and you could just copy that structure?

– Dirk Eddelbuettel
Nov 15 '18 at 16:31





This is too long for me to study in detail but the top-level question is: why are you reinventing package layout when existing packages with modules exist and you could just copy that structure?

– Dirk Eddelbuettel
Nov 15 '18 at 16:31













Dirk is right. You should make a package. For a course, I've made a quick tuto to make a package (including Rcpp and some includes in inst/) here.

– F. Privé
Nov 15 '18 at 19:49





Dirk is right. You should make a package. For a course, I've made a quick tuto to make a package (including Rcpp and some includes in inst/) here.

– F. Privé
Nov 15 '18 at 19:49













The top level question is: "'which' commands should I add and 'where', in order expose an Rcpp module containing a class inside the current namespace of the package, for the execution of a R file of the same package upon installation". My problem is that the R file cannot see the Rcpp module that is produced and compiled successfully inside the package, when installed. I used the Rcpp skeleton in order to demonstrate this error with the basic package Rcpp skeleton (when everything is declared appropriately), which should work with such a basic example (except if I forgot to declare something).

– John Sig
Nov 16 '18 at 14:43






The top level question is: "'which' commands should I add and 'where', in order expose an Rcpp module containing a class inside the current namespace of the package, for the execution of a R file of the same package upon installation". My problem is that the R file cannot see the Rcpp module that is produced and compiled successfully inside the package, when installed. I used the Rcpp skeleton in order to demonstrate this error with the basic package Rcpp skeleton (when everything is declared appropriately), which should work with such a basic example (except if I forgot to declare something).

– John Sig
Nov 16 '18 at 14:43














The skeleton generator used to have a 'create with Modules' mode, but we took that out. For a minimal package, look at one included with our unit tests; for (larger) real life ones my RcppRedis and RcppCNPy and RcppAnnoy packages may suit (but they may also distract you as they need more stuff). I'd start with the minimal one.

– Dirk Eddelbuettel
Nov 16 '18 at 21:41





The skeleton generator used to have a 'create with Modules' mode, but we took that out. For a minimal package, look at one included with our unit tests; for (larger) real life ones my RcppRedis and RcppCNPy and RcppAnnoy packages may suit (but they may also distract you as they need more stuff). I'd start with the minimal one.

– Dirk Eddelbuettel
Nov 16 '18 at 21:41













I have followed this basic example but it doesn't say anything about classes. Propably what I want is the similar command for loading a class instead of a function.

– John Sig
Nov 20 '18 at 17:42






I have followed this basic example but it doesn't say anything about classes. Propably what I want is the similar command for loading a class instead of a function.

– John Sig
Nov 20 '18 at 17:42













0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53323561%2frcpp-cannot-access-module-class-inside-r-code-of-the-same-package%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53323561%2frcpp-cannot-access-module-class-inside-r-code-of-the-same-package%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

How to read a connectionString WITH PROVIDER in .NET Core?

Node.js Script on GitHub Pages or Amazon S3

Museum of Modern and Contemporary Art of Trento and Rovereto