有没有办法从JavaScript运行R代码? [英] Is there a way to run R code from JavaScript?

查看:142
本文介绍了有没有办法从JavaScript运行R代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个项目,需要运行一些R代码才能进行一些数据分析。该项目主要使用JavaScript,我需要一种从JS运行R代码的方法。我的研究还没有找到任何好办法。有没有办法这样做?

I am working on a project which requires some R code to be run for some data analysis. The project is primarily in JavaScript, and I need a way to run R code from JS. My research has not found any good way to do it yet. Is there any way to do so?

另外,我没有R的经验(另一个人正在提供R代码)。

Also, I have next to no experience with R (another person is supplying the R code).

推荐答案

如果您可以在服务器上运行R代码,那么您应该看一下 OpenCPU 。它提供了一个REST API和相应的JavaScript库,用于将R代码发送到服务器并获取结果。特别是,它处理了将R作为服务器运行时可能出现的安全问题(R代码可以运行任意shell命令等)。您可以使用公共演示实例进行尝试,并且这个页面提供了一个简单的教程。

If you're ok with having the R code run on a server, then you should take a look at OpenCPU. It provides a REST API and corresponding JavaScript library for sending R code to the server and getting the results back. In particular, it takes care of the security problems that can arise from running R as a server (R code can run arbitrary shell commands, among other things). There are public demo instances that you can use to try it out, and this page provides a simple tutorial.

这篇关于有没有办法从JavaScript运行R代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆