使用该包svSocket
,我试图在服务器中执行一个通用表达式
expr <- "demo<-new.env()"
evalServer(con, expr, expr)
> evalServer(con, parse(text=expr))
Error in source(objcon, local = TRUE, echo = FALSE, verbose = FALSE) :
objcon:1:65: unexpected '<'
1: ..Last.value <-structure(expression(demo<-new.env()), srcfile = <
我怎样才能避免这种情况?PS:我需要以编程方式将对象创建到服务器中。例如demo
,将来自用户输入并将 paste()d 粘贴到上述字符串中。
可复现的例子###打开两个rsession
# run in the 1st rsession
require(svSocket)
startSocketServer()
# run in the 2nd rsession
con <- socketConnection(host = "localhost", port = 8888, blocking = FALSE)
expr <- "demo<-new.env()"
evalServer(con, expr, expr)