0

I'm guessing this is an easy question but I'm new to using CPP in R. I created an cpp function in a cpp file in R, say mean(a, b) using #include <Rcpp.h> and // [[Rcpp::export]] and sourceCpp to use that function in the rest of my R script. This works fine. I am trying to also use that function in another Cpp function file. It seems to be possible using #include <mean.h> but I don't understand the logic/way of doing that. How do I have to change my mean function script to have this work if this is possible ?

#include <Rcpp.h>
using namespace Rcpp;

// [[Rcpp::export]]
Rcpp::double mean(int a, int b) 
{ 
double mean = 0;
mean = (a+b)/2;
return mean 
}

Thanks a lot for the help

user20650
  • 24,654
  • 5
  • 56
  • 91
  • https://stackoverflow.com/questions/19745735/rcpp-function-calling-another-rcpp-function ; https://stackoverflow.com/questions/23527719/calling-a-rcpp-function-from-another-rcpp-function-while-building-an-r-package – user20650 Jul 29 '20 at 09:52
  • This is clearly a duplicate as we taught how to _use a package_ here for years. – Dirk Eddelbuettel Jul 29 '20 at 11:23

0 Answers0