Difference between revisions of "Using R in PostgreSQL"
(Created page with " ==Instructions on Use== To use R from pgAdmin III, follow the instructions in [https://www.bostongis.com/PrinterFriendly.aspx?content_name=postgresql_plr_tut01 this tutorial...") |
|||
Line 1: | Line 1: | ||
+ | |||
+ | ==Installing PL/R on the dbase server== | ||
+ | |||
+ | Check the version of the dbase by doing a | ||
+ | SELECT version(); | ||
+ | |||
+ | This gives us 9.5.10 | ||
+ | |||
+ | Then as root: | ||
+ | apt-get install postgresql-9.5-plr | ||
+ | |||
+ | Finally enable the extension in a dbase: | ||
+ | create extension plr; | ||
+ | |||
==Instructions on Use== | ==Instructions on Use== | ||
Line 6: | Line 20: | ||
[https://www.joeconway.com/presentations/plr-DWDC-2015.05.pdf Another possibly useful presentation on PL/R.] | [https://www.joeconway.com/presentations/plr-DWDC-2015.05.pdf Another possibly useful presentation on PL/R.] | ||
− | ==How PL/R was installed== | + | ==How PL/R was installed on the RDP== |
On 2018-01-18, PL/R was installed to allow PostgreSQL users to use R functions from SQL queries. It was installed using [https://www.bostongis.com/PrinterFriendly.aspx?content_name=postgresql_plr_tut01 this tutorial.] The link from the tutorial for PL/R doesn't work, I used [http://www.joeconway.com/plr.html this instead.] | On 2018-01-18, PL/R was installed to allow PostgreSQL users to use R functions from SQL queries. It was installed using [https://www.bostongis.com/PrinterFriendly.aspx?content_name=postgresql_plr_tut01 this tutorial.] The link from the tutorial for PL/R doesn't work, I used [http://www.joeconway.com/plr.html this instead.] | ||
It required R version 3.3.0 for PL/R to work with PostgreSQL 9.5. If the environmental variables R_HOME or PATH are edited so that they point to a different version of R, this might not work, and PL/R might have to be reinstalled. If the version of PostgreSQL is updated, both the R version and PL/R version will have to match it as well. | It required R version 3.3.0 for PL/R to work with PostgreSQL 9.5. If the environmental variables R_HOME or PATH are edited so that they point to a different version of R, this might not work, and PL/R might have to be reinstalled. If the version of PostgreSQL is updated, both the R version and PL/R version will have to match it as well. |
Revision as of 14:42, 6 February 2018
Installing PL/R on the dbase server
Check the version of the dbase by doing a
SELECT version();
This gives us 9.5.10
Then as root:
apt-get install postgresql-9.5-plr
Finally enable the extension in a dbase:
create extension plr;
Instructions on Use
To use R from pgAdmin III, follow the instructions in this tutorial: choose the database, click SQL, and run "CREATE EXTENSION plr;". This allows R functions to be used in this database from then on. You should be able to run the given examples in the tutorial after this is done. This was run on databases tigertest and template1.
Another possibly useful presentation on PL/R.
How PL/R was installed on the RDP
On 2018-01-18, PL/R was installed to allow PostgreSQL users to use R functions from SQL queries. It was installed using this tutorial. The link from the tutorial for PL/R doesn't work, I used this instead.
It required R version 3.3.0 for PL/R to work with PostgreSQL 9.5. If the environmental variables R_HOME or PATH are edited so that they point to a different version of R, this might not work, and PL/R might have to be reinstalled. If the version of PostgreSQL is updated, both the R version and PL/R version will have to match it as well.