ocpu.rpc
呼び出しを次のように変更してみてください。
var req = ocpu.rpc("test",{
x : mydata // <--- input : mydata
}, function(output){
$("tbody").empty();
$.each(output, function(index, value){
var html = "<tr><td>" + value.x + "</td><td>" + value.tv + "</td></tr>";
$("tbody").append(html);
});
input
関数が という名前の引数を期待しているときに、関数呼び出しが という名前の引数を渡すため、エラーが発生していますx
。
編集
完全に修正されたスクリプト (以下のコメントで言及されているもの):-
ocpu.seturl("//public.opencpu.org/ocpu/github/Klausos9/test/R")
//some example data
//to run with different data, edit and press Run at the top of the
//page
var mydata = 2;
//call R function: tvscore::tv(input=data)
$("#submitbutton").click(function(){ // <--- needed
var req = ocpu.rpc("test",{
x : mydata // <--- changed; input : mydata
}, function(output){
$("#output").text(output); // <--- changed; output.message
});
//optional
req.fail(function(){
alert("R returned an error: " + req.responseText);
});
});