I have a problem when trying to read .csv file with STATCONNECTORSRVLib (R(D)COM)
.
When I enter this code lines, it works:
var sc1 = new STATCONNECTORSRVLib.StatConnector();
sc1.Init("R");
sc1.EvaluateNoReturn("dataset=read.csv(file.choose())");
A pop up windows is opened, I choose file from c:\\
, it loads, and I can do calculation with it.
However, when I enter this almost exact code:
var sc1 = new STATCONNECTORSRVLib.StatConnector();
sc1.Init("R");
sc1.EvaluateNoReturn("dataset=read.csv('C:\\output.csv')");
I get this annoying exception:
"The server threw an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT))"
The line dataset=read.csv('C:\\output.csv')
works fine in R console.
What am I doing wrong, and how can my machine read file when I'm uploading manualy, but not automaticly?
I'm using: R 2.13.1
from RandFriend pack, and have all that is included within it.
OS Windows 7, 64 bit
All my projects in the solution are .NET 4, x86
In RStudio, click on the Workspace tab, and then on “Import Dataset” -> “From text file”. A file browser will open up, locate the . csv file and click Open.
csv() Function. read. csv() function in R Language is used to read “comma separated value” files. It imports data in the form of a data frame.
If your CSV file is reasonably small, you can just use the read. csv function from Base R to import it. When using this method, be sure to specify stringsAsFactors=FALSE so that R doesn't convert character or categorical variables into factors.
Reading in a . csv file is easy and is part of read. table in the R utils package (installed by default).
Not tested, but I think C# is treating converting your double backslashes to a single backslash, which R is then interpreting as an escape sequence. Try changing your string to
"dataset=read.csv('C:\\\\output.csv')"
or
@"dataset=read.csv('C:\\output.csv')"
or
"dataset=read.csv('C:/output.csv')"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With