embedR: Embedding R inside q
Download the appropriate release archive from releases page.
Unpack and install content of the archive
|Windows||Open the archive and copy content of the
Copy R_HOME/x64/.dll or R_HOME/i386/.dll to QHOME/w64 or QHOME/w32 respectively.
When calling R, you need to set
R_HOME. Required are:
# Linux/macOS export R_HOME=`R RHOME` # Windows for /f "delims=" %a in ('R RHOME') do @set R_HOME=%a
The library has four main methods:
Ropen: Initialise embedded R. Optional to call. Allows to set verbose mode as
Rcmd: run an R command, do not return a result
Rget: run an R command, return the result to q
Rset: set a variable in the R memory space
If using interactive plotting with
ggplot2 you will need to call
See examples folder.
Note: Examples are kdb+ 3.5 or higher.
e4.q is a simple example of plot 'moving window volatility' of returns. Converted from http://www.mayin.org/ajayshah/KB/R/html/p4.html
pcd.q is based on Corporate credit card transactions 2014-15.
Please download csv file from the link above and place it in the same folder as
pcd.q under name
Left for the reader :)