2016-04-04 8 views
0

私はrを統合して、Ubuntuマシン上でDeployR open 8.0.0を使用する非常に単純なWebアプリケーションを作成しようとしています。私はいけない...私は取得していますそのすべてのファイルをアップロードするためのボタンであると、それをthatsのDeployR javascript API

.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)) 

<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コード:私はクライアント側で次のコードを使用しています私が間違っている場所を知ってください...助けてください。

+0

構文は本当ですか?私は 'DeployR'を使用していませんが、javascriptコードは' .end(function(result)){...} 'の代わりに' .end(function(result){...}) 'のようにすべきではありません。 – cryo111

+0

@ cryo111その人を指摘してくれてありがとう、私は非常にjavascriptに新しいです:)。しかし残念ながら、それは助けにはならない。私は何がうまくいかないのか分かりません... 2日間... DeployRから少し失望しています。( –

+0

Firefoxを使用している場合、Firebugをインストールしましたか?あなたはhtml/javascriptコード。もしあなたがChromeを使用しているなら、Devtoolsメニューの 'Ctrl + Shift + i'に行きます。そして、少なくともhtml/javascriptエラーを除外することができます。 – cryo111

答えて

0

deployRのログを開始し、deployr.configure({cors:true、host: 'http://192.168.0.103:8000'、logging:true})を使用して取得しているものを確認できます。

また、アップロードボタンをクリックすると、ブラウザの開発ツールが起動します。スクリプトが失敗している場所を確認できます。