27 if (RInside::instancePtr())
throw std::runtime_error(
"Can only have one TRInterface instance");
28 fR =
new RInside(argc, argv, loadRcpp, verbose, interactive);
42 std::string osname =
Eval(
"Sys.info()['sysname']");
44 if (osname ==
"Linux") {
45 Execute(
"options(device='x11')");
47 Execute(
"options(device='quartz')");
64 rc =
fR->parseEval(code.
Data(), fans);
65 }
catch (Rcpp::exception &__ex__) {
66 Error(
"Eval",
"%s", __ex__.what());
67 forward_exception_to_r(__ex__) ;
69 Error(
"Eval",
"Can execute the requested code: %s", code.
Data());
81 fR->parseEvalQ(code.
Data());
82 }
catch (Rcpp::exception &__ex__) {
83 Error(
"Execute",
"%s", __ex__.what());
84 forward_exception_to_r(__ex__) ;
86 Error(
"Execute",
"Can execute the requested code: %s", code.
Data());
101 }
catch (Rcpp::exception &__ex__) {
102 Error(
"Eval",
"%s", __ex__.what());
103 forward_exception_to_r(__ex__) ;
105 Error(
"Eval",
"Can execute the requested code: %s", code.
Data());
116 fR->setVerbose(status);
128 fR->assign(*obj.
f, name.
Data());
142 char *
line = readline(
"[r]:");
144 if (std::string(line) ==
".q")
break;
146 if (*line) add_history(line);
156 const char *R_argv[] = {
"rootr",
"--gui=none",
"--no-save",
"--no-readline",
"--silent",
"--vanilla",
"--slave"};
157 gR =
new TRInterface(7, R_argv,
true,
false,
false);
159 gR->ProcessEventsLoop();
172 TString cmd =
"is.element('" + pkg +
"', installed.packages()[,1])";
173 return fR->parseEval(cmd.
Data());
179 TString cmd =
"require('" + pkg +
"',quiet=TRUE)";
180 return fR->parseEval(cmd.
Data());
186 TString cmd =
"install.packages('" + pkg +
"',repos='" + repos +
"',dependencies=TRUE)";
187 fR->parseEval(cmd.
Data());
192 #undef _POSIX_C_SOURCE
193 #include <R_ext/eventloop.h>
203 fd = R_checkActivity(usec, 0);
204 R_runHandlers(R_InputHandlers, fd);
SEXP RComp_assignTokenSym
SEXP RComp_getFileCompSym
XYZVector ans(TestRotation const &t, XYZVector const &v_in)
SEXP RComp_assignBufferSym
void Execute(const TString &code)
Method to eval R code.
Bool_t IsInstalled(TString pkg)
Method to verify if a package is installed.
static TRInterface * InstancePtr()
static method to get an TRInterface instance pointer
static ClassImp(TRInterface) static ROOT Bool_t statusEventLoop
SEXP RComp_completeTokenSym
TRInterface(const int argc=0, const char *argv[]=NULL, const bool loadRcpp=true, const bool verbose=false, const bool interactive=true)
The command line arguments are by deafult argc=0 and argv=NULL, The verbose mode is by default disabl...
SEXP RComp_assignStartSym
const char * Data() const
virtual void Sleep(UInt_t milliSec)
Sleep milliSec milli seconds.
void Assign(const T &var, const TString &name)
Template method to assign C++ variables into R enviroment.
Bool_t Install(TString pkg, TString repos="http://cran.r-project.org")
Method to install an R's package.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Int_t Run(void *arg=0)
Start the thread.
Bool_t Require(TString pkg)
Method to load an R's package.
This is a class to get ROOT's objects from R's objects
rl_completion_func_t * rl_attempted_completion_function
SEXP RComp_retrieveCompsSym
R__EXTERN TSystem * gSystem
char ** R_custom_completion(const char *text, int start, int end)
void SetStatus(Bool_t status)
TRObject is a current valid object?
void ProcessEventsLoop()
Init event loop in a thread to support actions in windows from R graphics system. ...
void Interactive()
Method to get a R prompt to work interactively with tab completation support.
void SetVerbose(Bool_t status)
Method to set verbose mode, that produce extra output.
static TRInterface & Instance()
static method to get an TRInterface instance reference
Binding operator[](const TString &name)
Mother of all ROOT objects.
Int_t Eval(const TString &code, TRObject &ans)
Method to eval R code and you get the result in a reference to TRObject.
This is a class to pass functions from ROOT to R
This is a class to create DataFrames from ROOT to R