首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >DeployR javascript API

DeployR javascript API
EN

Stack Overflow用户
提问于 2016-04-04 20:18:35
回答 1查看 212关注 0票数 0

我正在尝试集成r,以便在Ubuntu机上使用DeployR Open8.0.0创建一个非常简单的web应用程序。我在客户端使用了以下代码:

代码语言:javascript
复制
<html>
<head><script src="./js-client-library-7.4.3/browser/deployr.min.js"></script></head>
<body>
<script>
deployr.configure({cors: true, host: 'http://192.168.0.103:8000'})

var file = document.getElementById('csv-file').files[0]

deployr.auth('testuser','Aniruddha123')
        .io('/r/repository/file/upload')
        .attach(file, 'defects.csv')
        .io('/r/repository/script/execute')
        .data({filename: 'forestPredict.R', author: 'testuser', directory: 'root'})
        .end(function(result){
              ws = result.data.deployr.response.workspace;
              var preds = ws.objects[0].value;
              var error = ws.objects[1].value;
              document.write('<p>'+preds+'</p>'+'ERROR:' error)
              })


    </script>
    </body>
    </html>

和下面的R代码:

代码语言:javascript
复制
 .libPaths( c( .libPaths(), "/home/aniruddha/R/x86_64-pc-linux-gnu-library/3.2") )

library(randomForest)

defects = read.csv('defects.csv')
train = defects[is.na(defects$bugs)]
test = defects[!is.na(defects$bugs)]

forestTest = randomForest(bugs~.,train[-1])
preditions = predict(forestTest, test[-1])

test$bugs = round(preditions)

result = rbind(train, test)

trainPreds = predict(forestTest, train[-1])
meanError = mean(abs(train$bugs - trainPreds))

所有我得到的是一个上传文件的按钮,这就是它…我不知道我去哪里wrong...please帮助。

EN

回答 1

Stack Overflow用户

发布于 2016-04-18 15:52:51

您可以启动deployR的日志并检查使用deployr.configure获得的实际内容({cors: true,host:'http://192.168.0.103:8000',logging:true})。

此外,当您单击upload按钮时,启动浏览器的开发人员工具。您可以检查脚本出现故障的位置。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36402430

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档