We at STATWORX work a lot with R and we often use the same little helper functions within our projects. These functions ease our daily work life by reducing repetitive code parts or by creating overviews of our projects. At first, there was no plan to make a package, but soon I realised, that it will be much easier to share and improve those functions, if they are within a package. Up till the 24th December I will present one function each day from
helfRlein. So, on the 8th day of Christmas my true love gave to me…
What can it do?
This little helper returns the intersect of multiple vectors or lists. I found this function here, thought it is quite useful and adjusted it a bit to my liking.
intersect2(list(c(1:3), c(1:4)), list(c(1:2),c(1:3)), c(1:2))  1 2
Internally, the problem of finding the intersection is solved recursively if an element is a list and then stepwise with the next element.
Have a merry advent season!