# Using RNode in RDataFrame

**URL:** <https://root-forum.cern.ch/t/using-rnode-in-rdataframe/32320>\
**Category:** ROOT\
**Tags:** rdataframe\
**Created:** [January 16, 2019, 4:26pm UTC](https://root-forum.cern.ch/t/using-rnode-in-rdataframe/32320 "2019-01-16T16:26:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kpachal](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/kpachal/32/17760_2.png) [@kpachal](https://root-forum.cern.ch/u/kpachal)\
**Post date:** [January 16, 2019, 4:26pm UTC](https://root-forum.cern.ch/t/using-rnode-in-rdataframe/32320/1 "2019-01-16T16:26:04Z")

</div>

Hi there,

I’m trying to create a function like these ones:  
[https://root.cern.ch/doc/master/df025\_\_RNode\_8C\_source.html](https://root.cern.ch/doc/master/df025__RNode_8C_source.html)

to apply filters to an RDataFrame. But annoyingly I can’t seem to find the right thing to #include to gain access to RNode. My best guesses for header names have failed and I can’t find an example with full code.

Help?

* * *

_ROOT Version:_ Not Provided  
_Platform:_ Not Provided  
_Compiler:_ Not Provided

* * *

---

<div class="post-metadata">

**Author:** ![eguiraud](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eguiraud/32/32217_2.png) [@eguiraud](https://root-forum.cern.ch/u/eguiraud)\
**Post date:** [January 16, 2019, 4:54pm UTC](https://root-forum.cern.ch/t/using-rnode-in-rdataframe/32320/2 "2019-01-16T16:54:08Z")

</div>

Hi @kpachal,  
`ROOT::RNode` comes with `#include <ROOT/RDataFrame.hxx>`…if you have a recent enough ROOT version 😃 The tutorial you are linking to is for ROOT “master” (latest, unreleased ROOT). `ROOT::RNode` is not available e.g. in ROOT v6.14.

Could this be the issue?  
If yes, you can download a compiled version of ROOT master from our website and use that one, or source a nightly build of ROOT from lcg, or compile a more recent ROOT yourself.

Cheers,  
Enrico

---

<div class="post-metadata">

**Author:** ![kpachal](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/kpachal/32/17760_2.png) [@kpachal](https://root-forum.cern.ch/u/kpachal)\
**Post date:** [January 17, 2019, 8:52am UTC](https://root-forum.cern.ch/t/using-rnode-in-rdataframe/32320/3 "2019-01-17T08:52:05Z")

</div>

Hi Enrico,

Ah – that’d be it! I was using 6.14. I’ll try to get a more recent version, but I’m on a shared cluster so I’ll have to use what’s available. In case I’m stuck with 6.14, is there an equivalent way to do this there?

Cheers,  
Kate

---

<div class="post-metadata">

**Author:** ![eguiraud](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eguiraud/32/32217_2.png) [@eguiraud](https://root-forum.cern.ch/u/eguiraud)\
**Post date:** [January 17, 2019, 9:56am UTC](https://root-forum.cern.ch/t/using-rnode-in-rdataframe/32320/4 "2019-01-17T09:56:21Z")

</div>

Hi,  
note that there is no more recent _release_ of ROOT (for now: v6.16 is coming soon, with all the RNode goodness). But you can get a nightly build of ROOT master branch from the LCG releases on cmvs, if it’s available on your cluster: `source /cvmfs/sft-nightlies.cern.ch/lcg/views/dev3/latest/x86_64-slc6-gcc7-opt/setup.sh` – they are _kind of_ stable, ok to use most of the time.

Otherwise, depending on what you actually need to do with RNode, you can use a template function instead.  
With C++14 auto return types it’s pretty straightforward:

```auto
// c++14
template <typename RDF_t>
auto AddFilter(RDF_t node, string_view filterStr)
 {
    return node.Filter(filterStr);
 }

```

This becomes more awkward in C++11, where we have to specify the return type somehow (trailing return types to the rescue):

```auto
// c++11
template <typename RDF_t>
auto AddFilter(RDF_t node, string_view filterStr) -> decltype(node.Filter(filterStr))
 {
    return node.Filter(filterStr);
 }

```

Feel free to ask if you encounter any further problems.  
Cheers,  
Enrico

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [January 31, 2019, 9:56am UTC](https://root-forum.cern.ch/t/using-rnode-in-rdataframe/32320/5 "2019-01-31T09:56:27Z")

</div>

Closed on January 31, 2019, 9:56am UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
