I'm using R (http://www.r-project.org/) on a LAMP system with Rserve-php (https://code.google.com/p/rserve-php/). I would like to send a .csv file to R. Is this possible?
I tried using evalString(), but it did not work and returned the error below. The connection to R and the required files are okay. The output returns Hello World!
as expected.
evalString() from rcodetest.php:
<?php
require_once 'rconfig.php';
require 'rConnection.php';
//$test_cases = Rserve_Tests_Definition::$native_tests;
try {
echo '<p>Connecting to Rserve '.RSERVE_HOST;
$r = new Rserve_Connection(RSERVE_HOST);
echo ' OK</p>';
$result = $r->evalString('x ="Hello World!"; x');
echo $result;
$filex = $r->evalString("filename=('folder\\folder\\folder\\file.csv')");
$r->close();
} catch(Exception $e) {
echo $e;
}
?>
Error:
exception 'Rserve_Exception' with message 'Unexpected packet Data type (expect DT_SEXP)' in /path/rConnection.php:201 Stack trace: #0 /path/rConnection.php(237): Rserve_Connection->parseResponse(NULL, 0) #1 /path/rcodetest.php(14): Rserve_Connection- >evalString('filename=('fold...') #2 {main}
Try using read.table. This is if you are trying to process the .csv file.
Using
... is only assigning the string value to filename.
Also, the preferred assignment operator in R is
<-
.