Postgresql Table Function In R