Saturday, December 22, 2007

How to access R engine with Borland Delphi

R is powerful but it is not good looking (console interface high risk for your eyes :p ). Contrary, Delphi as a Rapid Application Development has a large number of extraordinary GUI library. The point here is.... it s very exciting for us if we can combine the good looking face of Delphi and the powerful of R in order to build our own the statistical application.
Can you imagine if you make a software calculating invers of a matrix with Delphi???? If the dimension of matrix is lower than 3x3 its okey, but it s very terrible if you have a huge matrix dimension.Fortunately, R libraries are open. We can access it with our Delphi. So it s not terrible anymore to built mathematical software with Delphi bcause we only access the R library from delphi, sending value to the R library parameters, gain the R result, and we show it on the beautiful GUI of Delphi...It was successful tricks on my final projects...and helped me gaining then bachelor degree of statistics..hehe).
Lets start!
First u must have Delphi is installed on your PC.
Second u must have R is installed on you PC. So many R version but here i used R 2.5.1. U can get it here.
Third, u have to installed RSrv250. It is server to make a communication between R and your application. It s also called (D) COM Server. (D)COM Server provides a COM-Interface to R as well as various COM objects and Active X controls for your applications.
Fourth...Restart your i mean computer...sorry :D.
Fifth...u need statconnector client and server. These are unit in pascal language available here.
That zip file contain files like this.

we must acces STATCONNECTORSRVLib_TLB.pas and STATCONNECTORCLNTLib_TLB.pas to make a connection between R and Delphi.
(Please search how to install component in Delphi if you dont know.
If you didnt found it, u can contact me at Yahoo!Messenger :

You can register your component with your own name, for example i register as RClient and RServer like the picture below (u must write down your own name at

procedure register

Look...i have Delphi VCL like that my Delphi UI like picture below

Here is the screen captured of my sources

I tried making a 3D plot by Delphi using R engine named scatterplot3d. Here is the screen captured of the result

Look! we can get the result of R engine execution on a delphi form. You can make another better GUI then mine depends on your demand.
My purpose has been explained now, that we can build statistical application easily with R's powerful engine and Delphi's beautiful GUI. U can implement it not only on library scatterplot3d but also all of R libraries.

Full sources code of this sample application can be downloaded at

Have a nice statistical soft programming..
mahendra statistika ITS 2002

Coming Soon :
How to Access STATISTICA engine with Delphi......


rahma said...

Good enough...
But it will be better if you add something else like book that support your R or delphi
Actually you are concern bout that
how to find you anywa

mahendra said...
This comment has been removed by the author.
mahendra said...

thanks a lot Rahma
So many book bout delphi programming but few R. R is not widespread using like Delphi, the sources knowledge o` R is (almost mandatory) the internet.

hanum said...

terkait dengan penerapan borland delphi, bisa diunduh artikel berikut

Guru said...

I would like to use delphi and R together. is this still available?