Accessing objects in opencpu sessions

依然范特西╮ 提交于 2020-01-02 21:59:11

问题


How do I access a specific object in an opencpu "session" in a subsequent function call?

Given a request, say to

/ocpu/library/base/R/eval

with parameter

 expr = "x <- 10; y <- 20"

Which gives

/ocpu/tmp/x08dfddafe3/R/.val
/ocpu/tmp/x08dfddafe3/R/x
/ocpu/tmp/x08dfddafe3/R/y
/ocpu/tmp/x08dfddafe3/stdout 
/ocpu/tmp/x08dfddafe3/source
/ocpu/tmp/x08dfddafe3/console
/ocpu/tmp/x08dfddafe3/info

Now .val has the value 20.

Suppose I wanted to pass x to

ocpu/library/stats/R/rnorm

Is there a quick way to that, something like

n = x08dfddafe3/R/x

in "pseudo"...


回答1:


Great question. Starting version 1.4.4 there are two ways of doing this:

  • You can use x08dfddafe3::x to refer to object x in the namespace of session x08dfddafe3.
  • You can pass the full URL http://your.server.com/ocpu/tmp/x08dfddafe3/R/x/rds. If network permits, this will automaticaly grab the object and unserialize it.


来源:https://stackoverflow.com/questions/24722550/accessing-objects-in-opencpu-sessions

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!