【问题标题】:object Object displayed in html pageobject html页面中显示的对象
【发布时间】:2016-10-19 10:52:10
【问题描述】:

我正在尝试在 opencpu 服务器中显示由 R 函数绘制的图形。 但是,它只在 html 页面中显示 [object Object]。以下是我的 AngularJS 控制器中的代码。

var req = ocpu.rpc("plotGraph", {
                filepath:"C:/Users/abc/Desktop/test.txt"
            }, function(output){
              $("#output").text(output);
            }); 

以下是plotGraph包中的R函数。

plotGraph <- function(filepath) {
  test.ecg <- read.table(filepath, quote="\"", comment.char="")
  ecg=ts(test.ecg)
  plot(ecg)

}

如何显示由 R 函数创建的绘图?

【问题讨论】:

    标签: javascript jquery angularjs r opencpu


    【解决方案1】:

    试试rplot:

    var req = $("#output").rplot("plotGraph", {
        filepath:"C:/Users/abc/Desktop/test.txt"
    });
    

    ocpu.rpc 只取回json。

    【讨论】:

    • 我试过了,但是控制台出现这个:OpenCPU error HTTP 400 cannot open the connection In call: file(file, "rt")
    • 这是因为 R 无法读取文件。要将数据放入您的 opencpu 服务器,请创建与数据库的连接或将文件另存为数据文件夹中的 rda。见这里:r-pkgs.had.co.nz/data.html
    • 感谢您的信息。会检查的。
    猜你喜欢
    • 2021-03-23
    • 2015-06-28
    • 2015-06-08
    • 2010-10-10
    • 1970-01-01
    • 2017-09-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多