[Rcpp-devel] Building of a package with roxygen2 using Rcpp in R version 5.1
Dirk Eddelbuettel
edd at debian.org
Wed Sep 5 20:55:22 CEST 2018
Hi Andre,
On 5 September 2018 at 15:37, André Luiz Molan wrote:
| Hi,
|
| I'm trying to create an R package using Rcpp. I am using the "Build" option
| from RStudio and roxygen2 package. My package is build with no error
| messages and normally loaded. However, when I call a function from the new
| package, I have the following message:
|
| *Error in .Call(<pointer: (nil)>, x) :
| NULL value passed as symbol address
| Called from: MakeSquare(x = val)*
|
|
| This is just a simple function I have created for testing:
|
|
| cppFunction('double MakeSquare(double x){
| double result = 0;
| result = x*x;
| return result;
|
| }')
cppFunction() (as well as sourceCpp)) are not meant for packages.
So create a package:
- Use File -> New Project -> New Directory -> R Package using Rcpp (this option
differs across RStudio versions).
- Alternatively use Rcpp.package.skeleton() (which has a help page as usual).
Add your functions to that package, edit and adjust as needed.
That should work, including with roxygen2.
Dirk
|
|
| The Rcpp function I have created above is called by another function:
|
| CalcSquare <- function(val1,val2){
| valResult <- (val1 + val2)/2
| valSquare <- MakeSquare(x = valResult)
| return(valSquare)
| }
|
|
| I have imported all the necessary packages, including Rcpp. I have looked
| at different discussion forums by I did not find any solution.
|
| I sincerely hope you could help me.
|
| Best regards,
|
| André
| _______________________________________________
| Rcpp-devel mailing list
| Rcpp-devel at lists.r-forge.r-project.org
| https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
--
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org
More information about the Rcpp-devel
mailing list