Process cmdProcess = new Process
{
StartInfo =
{
FileName = "cmd.exe",
WorkingDirectory = "C:/Program Files/R/R-3.0.2/bin",
Arguments = " /C R --slave --args $@ ",
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true,
RedirectStandardInput = true,
CreateNoWindow = true,
}
};
cmdProcess.Start();
cmdProcess.BeginOutputReadLine();
foreach (var item in File.ReadAllLines(“Audit.R”))
{
cmdProcess.StandardInput.WriteLine(item);
cmdProcess.OutputDataReceived += cmdProcess_OutputDataReceived;
}
}
And I try to get the output using the following event.
public void cmdProcess_OutputDataReceived(object sender,DataReceivedEventArgs e)
{
this.ResultText += e.Data + "\n";
}
I get the output repeated. This is my input R script,
getwd()
data<-read.csv("Audit.csv")
str(data)
Can anyone help me on this issue? Thanks