我在 Bluemix DashDB 服务上使用 R 脚本功能。我能够在 dashdb 控制台(从 Bluemix 仪表板启动)上生成绘图和可视化数据。我想知道如何制作一段外部代码来调用这个 R 脚本并使用结果。
该服务绑定到 NodeRED 应用程序。如果能以某种方式创建一个使用“http”节点处理请求并在底层 dashdb 服务中调用 R 脚本并提供结果图的流程,那就太好了。可能吗?
除了使用 dashdb Web 控制台/仪表板之外,还有其他方法可以运行 R 脚本吗?谢谢
===
2015/OCT/06 更新。这是我用来调用 R 的流程(请参阅流程编辑器上的更多评论):
[{"id":"e5480246.1ab8","type":"http in","name":"","url":"/rscript","method":"post","swaggerDoc":"","x":196,"y":541,"z":"c33d2d18.3cc2d","wires":[["e260a1e9.1d9f6"]]},{"id":"c0252e68.3fdad","type":"http response","name":"","x":848,"y":537,"z":"c33d2d18.3cc2d","wires":[]},{"id":"e260a1e9.1d9f6","type":"function","name":"","func":"msg.payload = \"cmd=RScriptRunScript&command=\"+msg.payload+\"&fileName=&profileName=BLUDB&userid=<YOUR_USER_HERE>\";\nmsg.headers = {\"content-type\": \"application/x-www-form-urlencoded\"};\nreturn msg;","outputs":1,"noerr":0,"x":420,"y":538,"z":"c33d2d18.3cc2d","wires":[["3842660d.c7bd9a"]]},{"id":"3842660d.c7bd9a","type":"http request","name":"R Script","method":"POST","ret":"txt","url":"<YOUR_URL_HERE>:8443/console/blushiftservices/BluShiftHttp.do","x":632,"y":536,"z":"c33d2d18.3cc2d","wires":[["c0252e68.3fdad"]]},{"id":"34a821fc.cb57de","type":"comment","name":"Instructions","info":"\nGet your Connect Info from the DashDB Console (under Connect > Connection Information).\n\nYou'll have to put your USER ID it in the \"function\" node and also configure the \"http request\" node to use Basic Auth and enter your credentials there.\nAlso, make sure your URL is right according to the info presented on the DashDB Console.","x":529,"y":665,"z":"c33d2d18.3cc2d","wires":[]},{"id":"253f405e.dac0c","type":"inject","name":"","topic":"","payload":"","payloadType":"none","repeat":"","crontab":"","once":false,"x":213,"y":610,"z":"c33d2d18.3cc2d","wires":[["ba5fe664.45a018"]]},{"id":"68e07153.971f9","type":"http request","name":"R Script","method":"POST","ret":"txt","url":"<YOUR_URL_HERE>:8443/console/blushiftservices/BluShiftHttp.do","x":637,"y":615,"z":"c33d2d18.3cc2d","wires":[["2b62647.fd49d9c"]]},{"id":"2b62647.fd49d9c","type":"debug","name":"","active":true,"console":"false","complete":"false","x":848,"y":615,"z":"c33d2d18.3cc2d","wires":[]},{"id":"ba5fe664.45a018","type":"function","name":"","func":"msg.payload = \"cmd=RScriptRunScript&command=numbers <- c(4, 23, 15, 12, 43, 54, 34, 23, 65, 87)\\nsortedNumbers = sort(numbers)\\nprint(sortedNumbers)\\n&fileName=&profileName=BLUDB&userid=<YOUR_USER_HERE>\";\nmsg.headers = {\"content-type\": \"application/x-www-form-urlencoded\"};\nreturn msg;\n\n\n","outputs":1,"noerr":0,"x":419,"y":615,"z":"c33d2d18.3cc2d","wires":[["68e07153.971f9"]]}]