Setting R_HOME for PL/R in PostgreSQL in Ubuntu

Problem

You want to use the PL/R extension in PostgreSQL, and after the package installation you need to set up the R_HOME in PostgresQL.

Solution

Add the following line to the bottom of your PostgreSQL configuration file as sudo:

sudo vi /etc/postgresql/9.3/main/postgresql.conf
R_HOME=/usr/bin/R