I'm struggling to find an examples of a PL/R function that could accepts two postgres tables. PL/R docs does not provide any such example.
To have a working examples lets considering using merge of two postgres tables on R side.
Having two tables in postgres
CREATE TABLE x (a numeric, b text);
CREATE TABLE y (a numeric, d text);
INSERT INTO x VALUES (1, 'a'),(2, 'b');
INSERT INTO y VALUES (2, 'b'),(3, 'c');
I'm looking to replace following query
SELECT * FROM x INNER JOIN y ON x.a=y.a;
With the PL/R function defined in R as:
my_function = function(x, y){
merge(x, y, by = "a")
}
I was able to call PL/R function which accepts single table, but not two.