In Chapter 3, Advanced Analytics – Paradigms, Tools, and Techniques, we were introduced to R programming. R is a very powerful programming language that has many built-in libraries for running statistical and analytical calculation or modeling. In this section, we will learn how R functions can be integrated to work with data in Greenplum. There are many ways in which we can run R on the data from Greenplum and we will now discuss on the following two important approaches:
R with standard DBI connector to Greenplum; in this case, R program connects to Postgres/Greenplum database, loads data into R client
PL/R—procedural language for SQL calls to R functions
//Database connector code require(TSP) require(fields) require(RPostgreSQL) drv <- dbDriver("PostgreSQL") conn <- dbConnect(drv, user="postgres", dbname="pgissc") sql.str <- "select id, st_x(location) as x, st_y(location...