Logo ROOT  
Reference Guide
Functions.C
Go to the documentation of this file.
1//script to test TRFunction
2#include<TRInterface.h>
3#include<TMath.h>
4double funv(TVectorD v)
5{
6 return v[0] * v[1];
7}
8
10{
11 m.Print();
12}
13
15{
16 std::cout << "hello " << s.Data() << std::endl;
17}
18
19//this prototype dont work because argument should be
20//an object to pass an array.
22{
23 return x[0] * par[0];
24}
25
27{
28 return x * 3;;
29}
30
31
32void Functions(TString type = "Import")
33{
36 if (type == "Export") {
37 std::cout << "-----------------------" << std::endl;
38 std::cout << "Testing FunctionExport" << std::endl;
39 std::cout << "-----------------------" << std::endl;
41 r << "print(funv(c(2,3)))";
42
44 r << "cat(funm(matrix(c(1,2,3,4),2,2)))";
45
47
48 r << "cat(funs('ROOTR'))";
49
51 r << "print(DiLog(2))";
52
53 r << "x <- seq(0,10,0.01)";
54 r << "y <- NULL ";
55 r << "for(i in seq(along=x)) { \
56 y <- c(y,DiLog(i)) \
57 }";
58
60 f4.SetFunction(fun4);
61 r["fun4"] << f4;
62 r << "print(fun4(1))";
63 } else {
64 std::cout << "-----------------------" << std::endl;
65 std::cout << "Testing FunctionImport " << std::endl;
66 std::cout << "-----------------------" << std::endl;
67 ROOT::R::TRFunctionImport print("print");
68 print("Hola");
69
71 ROOT::R::TRFunctionImport require("require");
72 ROOT::R::TRFunctionImport plot("plot");
73 ROOT::R::TRFunctionImport devoff("dev.off");
74//
76// ROOT::R::TRFunctionImport options("options");
78 ROOT::R::TRFunctionImport read("read.csv");
79 ROOT::R::TRFunctionImport head("head");
80 ROOT::R::TRFunctionImport aslist("as.list");
81
82 ROOT::R::TRFunctionImport options("options");
83 options(ROOT::R::Label["device"]="x11");
84
85
86 r<<"test <- function() x11";
88
89
91
92// dev();
93
94
95 options("device='x11'");
96//
97 ROOT::R::TRObject vector=c(1,2,3,4);
98 TVectorF v=vector;
99 TVectorF v2=c(11,22,33,44);
100 print(v);
101 print(v2);
102 ROOT::R::TRDataFrame obj=read("training.csv");
103
104// ROOT::R::TRDataFrame df(obj.As<ROOT::R::TRDataFrame>());
105 print(head(Rcpp::wrap(obj)));
106 print(head(obj));
107 x11();
108 plot(sin,0,6,ROOT::R::Label["type"]="s");
109 x11();
110 plot(sin,0,6,ROOT::R::Label["type"]="l");
111 x11();
112 plot(sin,0,6,ROOT::R::Label["type"]="p");
113
114
115
116// devoff();
117// print(vector);
118
119// require("C50");
120 }
121}
void funm(TMatrixD m)
Definition: Functions.C:9
Double_t fun3(Double_t *x, Double_t *par)
Definition: Functions.C:21
void funs(TString s)
Definition: Functions.C:14
Double_t fun4(Double_t x)
Definition: Functions.C:26
double funv(TVectorD v)
Definition: Functions.C:4
void Functions(TString type="Import")
Definition: Functions.C:32
ROOT::R::TRInterface & r
Definition: Object.C:4
#define c(i)
Definition: RSha256.hxx:101
const Bool_t kFALSE
Definition: RtypesCore.h:90
double Double_t
Definition: RtypesCore.h:57
int type
Definition: TGX11.cxx:120
double sin(double)
This is a class to create DataFrames from ROOT to R.
Definition: TRDataFrame.h:176
This is a class to pass functions from ROOT to R.
void SetFunction(T fun)
function to assign function to export, template method that supports a lot of function's prototypes
This is a class to pass functions from ROOT to R.
ROOT R was implemented using the R Project library and the modules Rcpp and RInside
Definition: TRInterface.h:136
static TRInterface & Instance()
static method to get an TRInterface instance reference
void SetVerbose(Bool_t status)
Method to set verbose mode, that produce extra output.
This is a class to get ROOT's objects from R's objects.
Definition: TRObject.h:70
Basic string class.
Definition: TString.h:131
Double_t x[n]
Definition: legend1.C:17
const Rcpp::internal::NamedPlaceHolder & Label
SEXP wrap(const TString &s)
Definition: RExports.h:67
static constexpr double s
Double_t DiLog(Double_t x)
Modified Struve functions of order 1.
Definition: TMath.cxx:110
Definition: test.py:1
auto * m
Definition: textangle.C:8