35 if (RInside::instancePtr())
throw std::runtime_error(
"Can only have one TRInterface instance");
36 fR =
new RInside(argc, argv, loadRcpp,
verbose, interactive);
50 std::string osname =
Eval(
"Sys.info()['sysname']");
53 if (!
gROOT->IsBatch()) {
57 Warning(
"OpenDisplay",
"system has no X11 thread support");
61 if (osname ==
"Linux") {
62 Execute(
"options(device='x11')");
64 Execute(
"options(device='quartz')");
74 if (
gR ==
this)
gR =
nullptr;
84 rc =
fR->parseEval(code.
Data(), fans);
85 }
catch (Rcpp::exception &__ex__) {
86 Error(
"Eval",
"%s", __ex__.what());
87 forward_exception_to_r(__ex__) ;
89 Error(
"Eval",
"Can execute the requested code: %s", code.
Data());
101 fR->parseEvalQ(code.
Data());
102 }
catch (Rcpp::exception &__ex__) {
103 Error(
"Execute",
"%s", __ex__.what());
104 forward_exception_to_r(__ex__) ;
106 Error(
"Execute",
"Can execute the requested code: %s", code.
Data());
120 rc =
fR->parseEval(code.
Data(), ans);
121 }
catch (Rcpp::exception &__ex__) {
122 Error(
"Eval",
"%s", __ex__.what());
123 forward_exception_to_r(__ex__) ;
125 Error(
"Eval",
"Can execute the requested code: %s", code.
Data());
136 fR->setVerbose(status);
148 fR->assign(*obj.
f,
name.Data());
164 if (std::string(
line) ==
".q")
break;
176 const Char_t *R_argv[] = {
"rootr",
"--gui=none",
"--no-save",
"--no-readline",
177 "--silent",
"--vanilla",
"--slave"};
193 TString cmd =
"is.element('" + pkg +
"', installed.packages()[,1])";
200 TString cmd =
"require('" + pkg +
"',quiet=TRUE)";
207 TString cmd =
"install.packages('" + pkg +
"',repos='" + repos +
"',dependencies=TRUE)";
213#undef _POSIX_C_SOURCE
214#include <R_ext/eventloop.h>
224 fd = R_checkActivity(usec, 0);
225 R_runHandlers(R_InputHandlers, fd);
rl_completion_func_t * rl_attempted_completion_function
static Bool_t statusEventLoop
static ROOT::R::TRInterface * gR
R__EXTERN TSystem * gSystem
This is a class to create DataFrames from ROOT to R.
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
TRInterface(const Int_t argc=0, const Char_t *argv[]=NULL, const Bool_t loadRcpp=true, const Bool_t verbose=false, const Bool_t interactive=true)
The command line arguments are by deafult argc=0 and argv=NULL, The verbose mode is by default disabl...
void Execute(const TString &code)
Method to eval R code.
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.
Bool_t IsInstalled(TString pkg)
Method to verify if a package is installed.
Bool_t Require(TString pkg)
Method to load an R's package.
Int_t Eval(const TString &code, TRObject &ans)
Method to eval R code and you get the result in a reference to TRObject.
void Interactive()
Method to get a R prompt to work interactively with tab completation support.
void ProcessEventsLoop()
Init event loop in a thread to support actions in windows from R graphics system.
Binding operator[](const TString &name)
void Assign(const T &var, const TString &name)
Template method to assign C++ variables into R enviroment.
static TRInterface * InstancePtr()
static method to get an TRInterface instance pointer
Bool_t Install(TString pkg, TString repos="http://cran.r-project.org")
Method to install an R's package.
This is a class to get ROOT's objects from R's objects.
void SetStatus(Bool_t status)
TRObject is a current valid object?
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Mother of all ROOT objects.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
const char * Data() const
virtual void Sleep(UInt_t milliSec)
Sleep milliSec milli seconds.
Int_t Run(void *arg=0)
Start the thread.
namespace associated R package for ROOT.
SEXP RComp_assignBufferSym
SEXP RComp_completeTokenSym
SEXP RComp_retrieveCompsSym
SEXP RComp_assignStartSym
SEXP RComp_assignTokenSym
SEXP RComp_getFileCompSym
char ** R_custom_completion(const char *text, int start, int end)