How can i connect to R language? If this is come true, the R can be used to calculate Big data.I find that neither Rsession nor Rserve support lazarus...Thank you.
Quote from: bills on April 07, 2018, 10:43:44 amHow can i connect to R language? If this is come true, the R can be used to calculate Big data.I find that neither Rsession nor Rserve support lazarus...Thank you.Sorry if you find this offensive BUT why don't you just use the R Studio. It was created for that purpose. https://www.rstudio.com/That is how I use R. Another alternative is to use Python, specifically rpy2.JD
Thank you JD. I am using R Studio. But i think if i can use R in my own program developed by lazarus, it will more powerful;
Quote from: bills on April 08, 2018, 02:29:18 amThank you JD. I am using R Studio. But i think if i can use R in my own program developed by lazarus, it will more powerful;Are you looking to run R from within a Pascal program or run Pascal code (in a dynamic library) from R? Seems like both should be possible.
Thank you Phil . I want my Pascal program connect to R and post data and cmd to R, then the R calculate and show the result. I have tryed many method but all failed.Thank you very much.
Quote from: bills on April 08, 2018, 03:39:00 amThank you Phil . I want my Pascal program connect to R and post data and cmd to R, then the R calculate and show the result. I have tryed many method but all failed.Thank you very much.Did you try saving commands to script file, send script file to R and capture output ?
Quote from: bigeno on April 08, 2018, 02:48:14 pmQuote from: bills on April 08, 2018, 03:39:00 amThank you Phil . I want my Pascal program connect to R and post data and cmd to R, then the R calculate and show the result. I have tryed many method but all failed.Thank you very much.Did you try saving commands to script file, send script file to R and capture output ?I'll try this method.Thank U. But i think if I use script file, the efficiency may be low.
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?
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.htmlsorry my English is poor.
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.
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 outputprocedure TForm1.OnOutputAvailable(const pBuffer: PByteArray; const pCount: integer);var s: string;begin s := TShellCommandRunner.BufferToString(pBuffer, pCount); Memo1.Append(ConsoleToUTF8(s));end;