21   r.Execute(
"print(version$version.string)");
 
   25   double std_dev_r  = 
r.Eval(
"sd(rnorm(10000))");
 
   26   std::vector<double> 
v = 
r.Eval(
"rnorm(10000)");
 
   28   std::cout << 
"standard deviation from R    = " << std_dev_r << std::endl;
 
   29   std::cout << 
"standard deviation from ROOT = " <<  std_dev_root << std::endl;
 
   31      Error(
"ROOT-R-Example",
"Different std-dev found");
 
   34   r << 
"mat<-matrix(c(1,2,3,4,5,6),2,3,byrow=TRUE)";
 
   36   std::array<double,6> 
a = 
r.Eval(
"seq(1:6)");
 
   40      Error(
"ROOT-R-Example",
"Different matrix  found");
 
   46   std::vector<double> v_root{1,2,3,4,5,6,7,8};
 
   49   bool isEqual = 
r.Eval(
"prod(v==v2)");
 
   51      Error(
"ROOT-R-Example",
"Different vector created");
 
   60   r << 
"y<-gaus_pdf(0,1,1)";
 
   61   double value_r = 
r[
"y"];
 
   63   std::cout << 
"Function gaussian(0,1,1) evaluated in  R    = " << value_r << std::endl;
 
   64   std::cout << 
"Function gaussian(0,1,1) evaluated in ROOT  = " <<  value_root << std::endl;
 
   65   if (value_r != value_root)
 
   66      Error(
"ROOT-R-Example",
"Different function value found in r = %f and ROOT = %f", value_r, value_root);
 
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
ROOT R was implemented using the R Project library and the modules Rcpp and RInside
static TRInterface & Instance()
static method to get an TRInterface instance reference
void Print(Option_t *option="") const override
Dump this marker with its attributes.
double normal_pdf(double x, double sigma=1, double x0=0)
Probability density function of the normal (Gaussian) distribution.
Bool_t AreEqualAbs(Double_t af, Double_t bf, Double_t epsilon)
Comparing floating points.
Double_t StdDev(Long64_t n, const T *a, const Double_t *w=nullptr)