Logo ROOT   6.14/05
Reference Guide
Proxy.C
Go to the documentation of this file.
1 #include<TRInterface.h>
2 #include<vector>
3 //script to test RExport a TRobjectProxy
4 void Proxy()
5 {
7  gR->SetVerbose(kTRUE);
8  //////////////////////////
9  //Getting values from R //
10  //////////////////////////
11  std::cout << "======Getting values from R ======\n";
12  TString s = gR->ParseEval("'ROOTR'");
13 
14  TVectorD v = gR->ParseEval("c(1,2,3,4)");
15  std::vector<Double_t> sv=gR->ParseEval("c(1.01,2,3,4)");
16  TMatrixD m = gR->ParseEval("matrix(c(1,2,3,4),2,2)");
17 
18  std::cout<<"-----------------------------------"<<endl;
19  std::cout << s << std::endl;
20  std::cout<<"-----------------------------------"<<endl;
21  v.Print();
22  std::cout<<"-----------------------------------"<<endl;
23  for(int i=0;i<sv.size();i++) std::cout<<sv[i]<<" "<<std::endl;
24  std::cout<<"-----------------------------------"<<endl;
25  m.Print();
26 
27  Double_t d = gR->ParseEval("1.1");
28  Float_t f = gR->ParseEval("0.1");
29  Int_t i = gR->ParseEval("1");
30 
31  std::cout << d << " " << f << " " << i << std::endl;
32 
33  ////////////////////////
34  //Passing values to R //
35  /////////////////////////
36 
37  std::cout << "======Passing values to R ======\n";
38  gR->Assign(s, "s");
39  gR->Parse("print(s)");
40  std::cout<<"-----------------------------------"<<endl;
41 
42  (*gR)["v"]=v;
43  gR->Parse("print(v)");
44  std::cout<<"-----------------------------------"<<endl;
45 
46  gR->Assign(sv, "sv");
47  gR->Parse("print(sv)");
48  std::cout<<"-----------------------------------"<<endl;
49 
50  gR->Assign(m, "m");
51  gR->Parse("print(m)");
52  std::cout<<"-----------------------------------"<<endl;
53 
54  gR->Assign(d, "d");
55  gR->Parse("print(d)");
56  std::cout<<"-----------------------------------"<<endl;
57 
58  gR->Assign(f, "f");
59  gR->Parse("print(f)");
60  std::cout<<"-----------------------------------"<<endl;
61 
62  gR->Assign(i, "i");
63  gR->Parse("print(i)");
64 
65 }
void Proxy()
Definition: Proxy.C:4
auto * m
Definition: textangle.C:8
float Float_t
Definition: RtypesCore.h:53
static TRInterface * InstancePtr()
static method to get an TRInterface instance pointer
TVectorT.
Definition: TMatrixTBase.h:77
Basic string class.
Definition: TString.h:131
#define f(i)
Definition: RSha256.hxx:104
int Int_t
Definition: RtypesCore.h:41
void Print(Option_t *option="") const
Print the vector as a list of elements.
Definition: TVectorT.cxx:1361
static ROOT::R::TRInterface * gR
Definition: TRInterface.cxx:22
TMatrixT.
Definition: TMatrixDfwd.h:22
void Assign(const T &var, const TString &name)
Template method to assign C++ variables into R enviroment.
Definition: TRInterface.h:255
SVector< double, 2 > v
Definition: Dict.h:5
#define d(i)
Definition: RSha256.hxx:102
double Double_t
Definition: RtypesCore.h:55
void SetVerbose(Bool_t status)
Method to set verbose mode, that produce extra output.
static constexpr double s
void Print(Option_t *name="") const
Print the matrix as a table of elements.
const Bool_t kTRUE
Definition: RtypesCore.h:87