* * *

Author Topic: How to connect to R languase  (Read 1506 times)

Almir.Bispo

  • Jr. Member
  • **
  • Posts: 66
  • CSV Comp DB is the Best NoSQL
    • CSV Comp DB (NoSQL)
Re: How to connect to R languase
« Reply #15 on: April 15, 2018, 05:16:54 pm »
This is not a good idea because if you can work directly with Object Pascal in Bigdata why use R? This is like use a Ferrari with firebird engine.
You can work with  object Pascal,CSV Comp DB and bigdata directly (just use ILDE-Pascal)
look this:
https://www.youtube.com/watch?v=qNaY8GknLWM&t=0s
https://www.youtube.com/watch?v=2XytLSkgyQw
download ILDE-Pascal here:
http://adltecnologia.blogspot.com.br
CSV Comp DB has a CQL languagem embedded on ILDE-Pascal
https://www.youtube.com/watch?v=O2aml1vBvq4&t=0s
CSV Comp DB Developer {Pascal Lover}

Phil

  • Hero Member
  • *****
  • Posts: 2549
Re: How to connect to R languase
« Reply #16 on: April 15, 2018, 05:19:12 pm »
This is not a good idea because if you can work directly with Object Pascal in Bigdata why use R? This is like use a Ferrari with firebird engine.

R is what statisticians and scientists know and use.

He _is_ using Pascal, for the frontend, where it might make more sense.

Almir.Bispo

  • Jr. Member
  • **
  • Posts: 66
  • CSV Comp DB is the Best NoSQL
    • CSV Comp DB (NoSQL)
Re: How to connect to R languase
« Reply #17 on: April 15, 2018, 05:27:49 pm »
Everything that you can do with R,so you can do with object Pascal (and much more,not onl frontend but statistical functions,graphs too)
CSV Comp DB Developer {Pascal Lover}

jamie

  • Hero Member
  • *****
  • Posts: 645
Re: How to connect to R languase
« Reply #18 on: April 15, 2018, 05:59:39 pm »
I agree, I can use the TChart for most of what R does and some generalized Pascal code for the rest.


engkin

  • Hero Member
  • *****
  • Posts: 1948
Re: How to connect to R languase
« Reply #19 on: April 15, 2018, 06:21:44 pm »
I am sad that the Rserve only support java/C++/Python/.NET/CLI/C#/Ruby.
Rserve does not support a specific language. It is a TCP/IP server. It comes with example clients for C++, Java, and PHP. Any person interested enough could develop a client for FPC.


On the other hand, under Windows, I would be more interested in calling R.Dll directly.

I don't know how helpful for you, but there used to be a Delphi interface on http://treetron.googlepages.com. You can still find a copy on Web Archives. It is old from 2009:
Quote
Most LGPL'ed R headers have been translated to PASCAL and you can interact with R on an equal (almost) level than the commonly used C code. It is about building packages! To embed R in a Delphi application you would have to translate some more headers.

I don't know if there is any recent/complete one.

wp

  • Hero Member
  • *****
  • Posts: 4388
Re: How to connect to R languase
« Reply #20 on: April 15, 2018, 10:10:05 pm »
My application uses the unit 'ShellCommandRunner', and click the button1 can get the correct result,but click the button2 i cant get the correct result.How can i do?

This is because TShellCommandRunnerThread sets FreeOnTerminate in its constructor. This means that the thread is destroyed automatically when it is finished. When you click Button2 afterwards the thread does not exist any more because you create it only once. You can fix this by creating the threads whenver the corresponding button is clicked:

Code: Pascal  [Select]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. var
  3.   th: TShellCommandRunnerThread;
  4. begin
  5.   th := TShellCommandRunnerThread.Create;
  6.   th.OnOutputAvailable := @OnOutputAvailable;
  7.   th.CommandLine := 'cmd /c dir c:\';
  8.   th.Start;
  9. end;
  10.  
  11. procedure TForm1.Button2Click(Sender: TObject);
  12. var
  13.   th: TShellCommandRunnerThread;
  14. begin
  15.   th := TShellCommandRunnerThread.Create;
  16.   th.OnOutputAvailable := @OnOutputAvailable;
  17.   th.CommandLine :=  'cmd /c dir d:\';
  18.   th.Start;
  19. end;
  20.  
  21. // Capture the output
  22. procedure TForm1.OnOutputAvailable(const pBuffer: PByteArray; const pCount: integer);
  23. var
  24.   s: string;
  25. begin
  26.   s := TShellCommandRunner.BufferToString(pBuffer, pCount);
  27.   Memo1.Append(ConsoleToUTF8(s));
  28. end;
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

bills

  • New member
  • *
  • Posts: 29
Re: How to connect to R languase
« Reply #21 on: April 16, 2018, 04:55:33 pm »
Thank you wp. I think i cant Frequently create and kill the R thread.

bills

  • New member
  • *
  • Posts: 29
Re: How to connect to R languase
« Reply #22 on: April 16, 2018, 05:01:28 pm »
I am sad that the Rserve only support java/C++/Python/.NET/CLI/C#/Ruby.
Rserve does not support a specific language. It is a TCP/IP server. It comes with example clients for C++, Java, and PHP. Any person interested enough could develop a client for FPC.


On the other hand, under Windows, I would be more interested in calling R.Dll directly.

I don't know how helpful for you, but there used to be a Delphi interface on http://treetron.googlepages.com. You can still find a copy on Web Archives. It is old from 2009:
Quote
Most LGPL'ed R headers have been translated to PASCAL and you can interact with R on an equal (almost) level than the commonly used C code. It is about building packages! To embed R in a Delphi application you would have to translate some more headers.

I don't know if there is any recent/complete one.

Thank you engkin.
This is a good solution. But my ability is poor. If i have time, I'll study and try to write a interface.

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus