1
var express = require('express');
var router = express.Router();
var session = require('express-session');
let Rserve = require("rserve-js");
var disease="fever";
var dataz="cough";
enter code here
let client = Rserve.connect("localhost", 6311, function() {
console.log("Connected to Rserve.");
client.eval("datas<-read.csv('~/Desktop/data.csv')", function(err, response) {
if (err) {
throw err;
}
console.log("table is loaded.");
client.eval("data<-datas[,c(2,3)]", function(err, response) {
if (err) {
throw err;
}
});
client.eval("print(data)", function(err, response) {
if (err) {
throw err;
}
});
// client.assign("x", disease);
// client.assign("y", dataz);
// client.eval("print(x)");
client.eval("result<-subset(data,Sym1=='fever' | Sym1=='sweating')", function(err, response) {
if (err) {
throw err;
}
});
client.eval("da<-summary(result)", function(err, response) {
if (err) {
throw err;
}
});
client.eval("print(da)", function(err, response) {
if (err) {
throw err;
}
//console.log(response.value); // shows dimension of iris table
});
var result= client.eval("summary(result)", function(err, response) {
if (err) {
throw err;
}
//console.log(response); // shows dimension of iris table
});
console.log(result);
});
});
module.exports = router;
我送如何使用來自節點js的rserve-js將參數動態地發送到R中的Rserve?
Sym1=='fever'
Sym1=='sweating'
評價爲靜態數據,但我希望它是動態的,所以,每次Sym1
可以是不同的,有沒有什麼辦法來分配一個變量?