12#ifndef ROOT_R_TRFunctionImport
13#define ROOT_R_TRFunctionImport
41 //defining functions to be used from R//
43 TRFunctionImport c("c");
44 TRFunctionImport list("list");
45 TRFunctionImport asformula("as.formula");
46 TRFunctionImport nls("nls");
47 TRFunctionImport confint("confint");
48 TRFunctionImport summary("summary");
49 TRFunctionImport print("print");
50 TRFunctionImport plot("plot");
51 TRFunctionImport lines("lines");
52 TRFunctionImport devnew("dev.new");
53 TRFunctionImport devoff("dev.off");
54 TRFunctionImport min("min");
55 TRFunctionImport max("max");
56 TRFunctionImport seq("seq");
57 TRFunctionImport predict("predict");
59 r<<"options(device='png')";//enable plot in png file
62 //doing the procedure //
64 TRObject xdata = c(-2,-1.64,-1.33,-0.7,0,0.45,1.2,1.64,2.32,2.9);
65 TRObject ydata = c(0.699369,0.700462,0.695354,1.03905,1.97389,2.41143,1.91091,0.919576,-0.730975,-1.42001);
71 //fit = nls(ydata ~ p1*cos(p2*xdata) + p2*sin(p1*xdata), start=list(p1=1,p2=0.2)) <- R code
72 TRObject fit = nls(asformula("ydata ~ p1*cos(p2*xdata) + p2*sin(p1*xdata)"),Label["data"]=data, Label["start"]=list(Label["p1"]=1,Label["p2"]=0.2));
77 devnew("Fitting Regression");
80 TRObject xgrid=seq(min(xdata),max(xdata),Label["len"]=10);
81 lines(xgrid,predict(fit,xgrid),Label["col"] = "green");
88 Formula: ydata ~ p1 * cos(p2 * xdata) + p2 * sin(p1 * xdata)
91 Estimate Std. Error t value Pr(>|t|)
92 p1 1.881851 0.027430 68.61 2.27e-12 ***
93 p2 0.700230 0.009153 76.51 9.50e-13 ***
95 Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
97 Residual standard error: 0.08202 on 8 degrees of freedom
99 Number of iterations to convergence: 7
100 Achieved convergence tolerance: 2.189e-06
102 Waiting for profiling to be done...
104 p1 1.8206081 1.9442365
105 p2 0.6794193 0.7209843
107 <h2>Users Guide </h2>
108 <a href="https://oproject.org/pages/ROOT%20R%20Users%20Guide"> https://oproject.org/pages/ROOT R Users Guide</a><br>
#define ClassDef(name, id)
This is a class to pass functions from ROOT to R.
TRFunctionImport(const Rcpp::Function &fun)
TRFunctionImport constructor for Rcpp::DataFrame.
ROOT R was implemented using the R Project library and the modules Rcpp and RInside
This is a class to get ROOT's objects from R's objects.
Mother of all ROOT objects.
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.