However, I am not able to use external R packages available from CRAN. The session below describes both Docker commands and SQL used. This session was run on OSX using Docker Machine.
bash-3.2$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d6b944445237 monetdb/monetdb-r-docker:latest "/usr/bin/supervisord" 13 minutes ago Up 13 minutes 0.0.0.0:32768->50000/tcp monetdb-r-docker
bash-3.2$ docker exec -it monetdb-r-docker mclient db
user:monetdb
password:
Welcome to mclient, the MonetDB/SQL interactive terminal (Jul2015-SP4)
Database: MonetDB v11.21.19 (Jul2015-SP4), 'mapi:monetdb://d6b944445237:50000/db'
Type \q to quit, \? for a list of available commands
auto commit mode: on
# Create and use a function to show that MonetDB with basic R expressions works:
sql>CREATE FUNCTION test_add() RETURNS DOUBLE LANGUAGE R {
1 + 1 };
operation successful (1.254ms)
sql>SELECT test_add();
+--------------------------+
| test_add |
+==========================+
| 2 |
+--------------------------+
# Add only the library function call to the function just shown (and give the function a new name). The function is created successfully, but an error occurs when the function is invoked in a query:
sql>CREATE FUNCTION test_library() RETURNS DOUBLE LANGUAGE R { library("ggplot2"); 1 + 1 };
operation successful (1.378ms)
sql>SELECT test_library();
Error running R expression. Error message: Error in .library.original(package, help, pos, lib.loc, character.only = T, :
there is no package called 'ggplot2'
Calls: as.data.frame -> <Anonymous> -> library -> .library.original
sql>