如何将数据从php from发送到R脚本,以便基于该数据执行某些操作?
我已经使用PHP构建了一个表单,其中包含一些问题,每当用户单击submit按钮时,生成的CSV就会传递给R脚本进行预测。正在生成CSV,但未将其传递到R脚本,请提供帮助 我已尝试使用exec();但它似乎不起作用,或者我做错了如何将数据从php from发送到R脚本,以便基于该数据执行某些操作?,php,r,database,html,machine-learning,Php,R,Database,Html,Machine Learning,我已经使用PHP构建了一个表单,其中包含一些问题,每当用户单击submit按钮时,生成的CSV就会传递给R脚本进行预测。正在生成CSV,但未将其传递到R脚本,请提供帮助 我已尝试使用exec();但它似乎不起作用,或者我做错了 <?php if(isset($_POST['submit'])){ //collect form data $Pleasure=$_POST['Pleasure']; $Feeling=$_POST['Feeling']; f(!i
<?php
if(isset($_POST['submit'])){
//collect form data
$Pleasure=$_POST['Pleasure'];
$Feeling=$_POST['Feeling'];
f(!isset($error)){
# Title of the CSV
$Content = "PleasureDoing,Feeling\n";
//set the data of the CSV
$Content .= "$Pleasure,$Feeling";
# set the file name and create CSV file
$FileName = "formdata-".date("d-m-y-h:i:s").".csv";
header('Content-Type: application/csv');
header('Content-Disposition: attachment; filename="' . $FileName . '"');
echo $Content;
exec('C:\\"Program Files"\\R\\R-3.5.1\\bin\\Rscript.exe C:\xampp\htdocs\predict\Rscript.R ');
exit();
}
}
//if their are errors display them
if(isset($error)){
foreach($error as $error){
echo "<p style='color:#ff0000'>$error</p>";
}
}
?>
<form action='' method='post'>
<h2>Little interest or pleasure in doing things</h2>
<input type="radio" name="Pleasure" value=" Not at all"> Not at all<br>
<input type="radio" name="Pleasure" value="Sometimes">Sometimes<br>
<input type="radio" name="Pleasure" value="Several days">Several days<br>
<input type="radio" name="Pleasure" value="More than half the days">More than half the days<br>
<input type="radio" name="Pleasure" value="Nearly everyday">Nearly everyday<br>
<h2>Feeling down, depressed, or hopeless</h2>
<input type="radio" name="Feeling" value=" Not at all"> Not at all<br>
<input type="radio" name="Feeling" value="Sometimes">Sometimes<br>
<input type="radio" name="Feeling" value="Several days">Several days<br>
<input type="radio" name="Feeling" value="More than half the days">More than half the days<br>
<input type="radio" name="Feeling" value="Nearly everyday">Nearly everyday<br>
<p><input type='submit' name='submit' value='Submit'></p>
</form>
SO rather then the code to generate the csv i want the code to send the data to the R scrip, how should i proceed or do it ?
PHP创建一个数据文件
R读取文件
PHP创建一个数据文件
R读取文件
是,PHP将生成本应发送到R脚本的CSV,但脚本仅生成CSV,而不重定向它并执行R脚本:`df_main是,PHP将生成本应发送到R脚本的CSV,但脚本仅生成CSV,而不重定向它并执行R脚本脚本::`df_main