我想将 .csv 文件读入 R。我已经能够将文件的绝对路径发送到 R,它将通过$test
下面 PHP 代码中的变量返回它。$r->evalString("data<-read.csv(filetim,header=TRUE)");
返回我在下面列出的错误。关于导致错误的任何想法?
<?php
require_once 'rconfig.php';
require 'rConnection.php';
try {
# Connect to R via Rserve
echo '<p>Connecting to Rserve '.RSERVE_HOST;
$r = new Rserve_Connection(RSERVE_HOST);
echo ' Connection OK</p>';
# Associate filename with the file's absolute path
$r->evalString("filetim=('folder/folder/folder/file.csv')");
$r->evalString("filebob=('folder/folder/folder/file2.csv')");
# Check if the filename is being stored
$test = $r->evalString("filebob");
echo $test;
# Read the .csv file into variable "data"
$r->evalString("data<-read.csv(filetim,header=TRUE)");
$r->close();
} catch(Exception $e) {
echo $e;
}
?>
错误:
'Rserve_Exception' with message 'unable to evaluate' in /folder/folder/folder/folder/folder/rConnection.php:239 Stack trace: #0 /folder/folder/folder/folder/folder/rcodetest.php(17): Rserve_Connection->evalString('data<-read.csv(f...') #1 {main}