I think that with this system, we can do a real data analysis using multiple languages and working between they
In [1]:
#include <iostream>
#include <TCanvas.h>
#include <TF1.h>
#include <TRInterface.h>
In [2]:
TF1 f("f","sin(x)",0,6);
f.Draw();
gPad->Draw();
In [ ]:
int *a=0;
a[10]=0;
In [3]:
%%cpp -d
void MyFunction()
{
std::cout<<"Hello from MyFucntion"<<std::endl;
}
In [4]:
MyFunction();
In [5]:
%%cpp -d
class Test
{
private:
std::string msg;
public:
Test(std::string _msg);
void Print();
};
Test::Test(std::string _msg)
{
msg=_msg;
}
void Test::Print()
{
std::cout<<msg<<std::endl;
}
In [6]:
Test t("Hello from Class");
t.Print();
In [7]:
%%doc -c TTree
In [8]:
%%shell
for i in $(seq 1 1 10)
do
echo -n $i" "
done
In [ ]:
%%html
<iframe width="100%" height="500" src="https://www.youtube.com/embed/pQhbhpU9Wrg" frameborder="0" allowfullscreen></iframe>
In [9]:
%%time
for(int i=0;i<3;i++)
{
sleep(1);
}
std::cout<<"Done!"<<std::endl;
In [10]:
%%python
from ROOT import TF1, gPad
print("Testing Python")
f=TF1("f","tanh(x)",-10,10)
f.Draw()
gPad.Draw()
print("DONE!")
In [11]:
%%r
x <- seq(-4, 4, length=100)
hx <- dnorm(x)
plot(x, hx, type="l", lty=1, xlab="x value",
ylab="Density", main="Normal Distributions",col="blue")
legend("topright", inset=.05, title="Distributions",
c("normal"), lwd=2, lty=c(1), col="blue")
In [12]:
ROOT::R::TRInterface &r=ROOT::R::TRInterface::Instance();
std::vector<float> x;
std::vector<float> hx;
r["x"]>>x;
r["hx"]>>hx;
TCanvas c("c");
TGraph g(x.size(),&x.begin()[0],&hx.begin()[0]);
g.Draw();
c.Draw();
In [13]:
%%r
attach(mtcars)
par(mfrow=c(2,2))
plot(wt,mpg, main="Scatterplot of wt vs. mpg")
plot(wt,disp, main="Scatterplot of wt vs disp")
hist(wt, main="Histogram of wt")
boxplot(wt, main="Boxplot of wt")
In [14]:
%%r
x <- seq(-4, 4, length=100)
hx <- dnorm(x)
degf <- c(1, 3, 8, 30)
colors <- c("red", "blue", "darkgreen", "gold", "black")
labels <- c("df=1", "df=3", "df=8", "df=30", "normal")
plot(x, hx, type="l", lty=2, xlab="x value",
ylab="Density", main="Comparison of t Distributions")
for (i in 1:4){
lines(x, dt(x,degf[i]), lwd=2, col=colors[i])
}
legend("topright", inset=.05, title="Distributions",
labels, lwd=2, lty=c(1, 1, 1, 1, 2), col=colors)
In [ ]: