plr

Loading, listing, and using R Modules and Functions in PL/R

I am having difficulty with: Listing the R packages and functions available to PostgreSQL. Installing a package (such as Kendall) for use with PL/R Calling an R function within PostgreSQL Listing Available R Packages Q.1. How do you find out what R modules have been loaded? SELECT * FROM r_typenames(); That shows the types that a...

Root mean square deviation on binned GAM results using R

Background A PostgreSQL database uses PL/R to call R functions. An R call to calculate Spearman's correlation looks as follows: cor( rank(x), rank(y) ) Also in R, a naïve calculation of a fitted generalized additive model (GAM): data.frame( x, fitted( gam( y ~ s(x) ) ) ) Here x represents the years from 1900 to 2009 and y is the a...

Return query results into an array

The following code snippet creates three arrays, which are passed into a PL/R function. FOR s_id, s_latitude, s_longitude IN SELECT s.id, s.latitude_decimal, s.longitude_decimal FROM climate.station s WHERE s.applicable AND s.latitude_decimal BETWEEN box.latitude_min AND box.latitude_max AND s.longitud...