问题描述
我对R
很陌生.我正在尝试做的是能够从另一个应用程序(Java)加载URL,该应用程序将运行R
脚本并输出JSON
,以便我的应用程序可以使用它.
I am pretty new with R
. What I am trying to do is to be able to load a URL from another application (Java) which will run an R
script and output a JSON
so my application can work with it.
我了解到有一些像shiny
这样的框架可以用作R的网络服务器,但是我找不到有关如何通过URL传递参数以便R可以使用这些框架的文档.
I understand there are some frameworks like shiny
which act as web servers for R, but I can't find documentation on those frameworks on how to pass parameters via the URL so R can use them.
理想情况下,我需要调用一个网址,例如:
Ideally I will need to call a URL like:
http://127.0.0.1/R/param1/param2
然后该URL将调用R脚本,该脚本将使用param1
和param2
执行某些功能,并返回一个JSON
,然后我将从我的应用程序中读取该文件.
And that URL will call an R script which will use param1
and param2
to perform some functions and return a JSON
which I will then read from my app.
推荐答案
如果尚未这样做,请结帐> DeployR] .您也可以将问题发布到 DeployR Google网上论坛以寻求帮助.
If you have not done so yet please checkout [DeployR]. You can also post questions to the DeployR Google Group for help.
为全面披露我是 DeployR
概述
DeployR是一种集成技术,用于在Web,桌面,移动和仪表板应用程序以及后端系统中部署R分析. DeployR将您的R脚本转换为分析Web服务,因此R代码可以由在安全服务器上运行的应用程序轻松执行.
DeployR is an integration technology for deploying R analytics inside web, desktop,mobile,and dashboard applications as well as backend systems. DeployR turns your R scripts into analytics web services, so R code can be easily executed by applications running on a secure server.
使用分析Web服务,DeployR还解决了那些在现有IT基础架构中同时采用基于R的分析所面临的关键集成问题.这些服务使应用程序开发人员可以轻松地与数据科学家合作,以在无需任何R编程知识的情况下将R分析集成到他们的应用程序中.
Using analytics web services, DeployR also solves key integration problems faced by those adopting R-based analytics alongside existing IT infrastructure. These services make it easy for application developers to collaborate with data scientists to integrate R analytics into their applications without any R programming knowledge.
DeployR有两个版本: DeployR Open 和 DeployR Enterprise . DeployR Open是一种免费的开源解决方案,是原型设计,构建和部署非关键业务应用程序的理想选择. DeployR Enterprise 可扩展到关键业务应用程序,并为生产级工作负载提供支持,并与流行的企业安全解决方案(如单点登录(SSO),轻型目录访问协议(LDAP))无缝集成),Active Directory或可插拔身份验证模块(PAM).
DeployR is available in two editions: DeployR Open and DeployR Enterprise. DeployR Open is a free, open source solution that is ideal for prototyping, building, and deploying non-critical business applications. DeployR Enterprise scales for business-critical applications and offers support for production-grade workloads, as well as seamless integration with popular enterprise security solutions such as single sign-on (SSO), Lightweight Directory Access Protocol (LDAP), Active Directory, or Pluggable Authentication Modules (PAM).
长官. DeployR适用于可能不了解R的数据科学家以及应用程序开发人员.
Prefect. DeployR is intended for both the Data Scientist as well as the application developer who might not know R.
DeployR可以很好地退出.协助您的应用程序之间的通信和DeployR服务器(将执行您的R),有 DeployR客户端库.
DeployR does this quit well. To aid in the communication between your applicationand the DeployR server (that will be executing your R) there are the DeployR Client libraries.
根据您的需求,DeployR在以下位置提供开箱即用的客户端库"支持:
Depending on your needs, DeployR has out-of-the-box 'client library' support in:
- Java客户端库:
https://github.com/deployr/java-client-library
- .NET客户端库:
https://github.com/deployr/dotnet-client-library
- JavaScript和Node.js库:
https://github.com/deployr/js-client-library
- Java-client-library:
https://github.com/deployr/java-client-library
- .NET-client-library:
https://github.com/deployr/dotnet-client-library
- JavaScript and Node.js-library:
https://github.com/deployr/js-client-library
DeployR还支持 RBroker框架
DeployR also supports the RBroker Framework
您的用例或运行时是否应该预期大量工作量或需要定期,计划或批处理.
should your use-case or runtime anticipate a high-volume workload or the need for periodic, scheduled or batch processing.
DeployR通过其APIS充当您的分析引擎.基本上认为它是将您的R脚本转化为安全的分析Web服务,以像任何其他方式一样使用其他网络服务.
DeployR acts as your analytics engine through its APIS. Basically think of it as turning your R scripts into secure analytic web services to be consumed like any other web service.
通过参数
在DeployR中将参数传递到R脚本很容易,但是您必须了解您正在从非R语言将参数传递到R脚本.因此,需要一些数据编码"完毕.例如,将Java字符串转换为R character
或将Java布尔值转换为R logical
...DeployR客户端库或RBroker使此操作变得容易.
Passing parameters to an R Script in DeployR is easy, however you have to understand that you are passing parameters to an R Script from a language that is not R. As such, there is some 'Data Encoding' that needs to be done. For example, turn your Java String into an R character
or your Java boolean to an R logical
...The DeployR Client library or RBroker makes this easy.
听起来好像您正在使用Java,所以首先查看Java教程 java-example-client-basics https://github.com/deployr/java-example-rbroker-basics
为您提供一些上下文,然后在 java下检查许多Java示例. -example-client-data-io https://github.com/deployr/java-example-client-data-io
.示例源完全可用,因此应该为您提供所需的一切为了了解如何从应用程序执行基本I/O到DeployR服务器以进行R分析.
It sounds like you are using Java, so first review the Java tutorial java-example-client-basics https://github.com/deployr/java-example-rbroker-basics
to give you some context then checkout the many Java examples under java-example-client-data-io https://github.com/deployr/java-example-client-data-io
.The example source is fully available so that should give you everything you needin order to understand how to do basic I/O from your application to the DeployR server for your R analytics.
我建议如上所述使用 DeployR Client库进行通讯,
I suggest using the DeployR Client libraries for your communication as described above, it does just that.
与往常一样,将问题发布到 DeployR Google小组 https://groups.google.com/forum/#!forum/deployr
寻求帮助.
As always post questions to the DeployR Google Group https://groups.google.com/forum/#!forum/deployr
for help.
这篇关于将R作为具有参数的Web服务调用并加载JSON?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!