Forum > General

How to connect to R languase

<< < (3/6) > >>

bills:

--- Quote from: wp on April 09, 2018, 08:55:36 am ---You don't say anything about what you want to achieve with R. Maybe the built-in math and statistical functions in the units math and in FPC's numlib (http://wiki.lazarus.freepascal.org/NumLib_Documentation), or in external libraries such as DMath (https://sourceforge.net/projects/dmath/) can achieve what you need?

--- End quote ---

The R can implement machine learning, but R's windows programing ability is poor. I have developed my own data processing program. I want to pass data to R by my program, and tell R to do  machine learning or other Statistical calculation, then the  R return results,such as data, Chart...

The c++, .net, java, php, python have their own api or class to connect to R, but it seems that lazarus has not.

Here is c++ example:http://finzi.psych.upenn.edu/R/library/RcppClassicExamples/html/RcppVector.html

sorry my English is poor.

bigeno:

--- Quote from: bills on April 09, 2018, 03:20:30 pm ---The R can implement machine learning, but R's windows programing ability is poor. I have developed my own data processing program. I want to pass data to R by my program, and tell R to do  machine learning or other Statistical calculation, then the  R return results,such as data, Chart...

The c++, .net, java, php, python have their own api or class to connect to R, but it seems that lazarus has not.

Here is c++ example:http://finzi.psych.upenn.edu/R/library/RcppClassicExamples/html/RcppVector.html

sorry my English is poor.

--- End quote ---

there is DCOM server for R, I don't know if is still developed but you can try connect via com interface https://cran.r-project.org/contrib/extra/dcom/00ReadMe.html

bills:
I am sad that the Rserve only support java/C++/Python/.NET/CLI/C#/Ruby.

wp:
First of all: I don't know anything about R. But I guess that R can be controlled by a script of commands. In this case, your program would create the script and store it in a temporary file, call R (RScript?) in a separate process and pass the script file to it as a parameter. Finally your program would catch the output of R, parse it and extract the results.

Have a look at my "gnuplotter" which does the same with gnuplot: https://forum.lazarus.freepascal.org/index.php/topic,23839.msg253759.html#msg253759.

bills:

--- Quote from: wp on April 14, 2018, 06:16:32 pm ---First of all: I don't know anything about R. But I guess that R can be controlled by a script of commands. In this case, your program would create the script and store it in a temporary file, call R (RScript?) in a separate process and pass the script file to it as a parameter. Finally your program would catch the output of R, parse it and extract the results.

Have a look at my "gnuplotter" which does the same with gnuplot: https://forum.lazarus.freepascal.org/index.php/topic,23839.msg253759.html#msg253759.

--- End quote ---

thank you wp.
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?

--- Quote ---procedure TForm1.FormCreate(Sender: TObject);
begin
  th := TShellCommandRunnerThread.Create;
  th.OnOutputAvailable := @OnOutputAvailable;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  th.CommandLine := 'cmd /c dir c:\';
  th.Start;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  th.CommandLine :=  'cmd /c dir d:\';
  th.Start;
end;

// Capture the output
procedure TForm1.OnOutputAvailable(const pBuffer: PByteArray; const pCount: integer);
var
  s: string;
begin
  s := TShellCommandRunner.BufferToString(pBuffer, pCount);
  Memo1.Append(ConsoleToUTF8(s));
end; 
--- End quote ---

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version