2017-11-06 7 views
0

誰かが私の問題を助けてくれるかもしれません。RapidminerのRスクリプト

私はRapidMinerで働いているとR-スクリプトオペレータと、次のR-スクリプトで369 X 258出現matixプロセス:プロセスは、エラーメッセージ "で終了し、グラフを作成した後

# rm_main is a mandatory function, 
# the number of arguments has to be the number of input ports (can be none) 
rm_main = function(data) 
{ 
total_occurrence <- colSums(data) 
data_matrix <- as.matrix(data) 
co_occurrence <- t(data_matrix) %*% data_matrix 
library(igraph) 
graph <- graph.adjacency(co_occurrence, 
          weighted = TRUE, 
          mode="undirected", 
          diag = FALSE) 
tkplot(graph, 
     vertex.label=names(data), 
     vertex.size=total_occurrence*1, 
     edge.width=E(graph)$weight*1,) 

dev.copy (tk_postscript, file= '/home/knecht/r-graph.pdf') 
dev.off() 
} 

をヌルデバイスからコピーできません "。

私の質問は、どうやってポストスクリプトやpngのようなファイルにグラフを印刷できますか?

種類について

トビアス

答えて

1

私はので、私はむしろ、(そう、とにかく苦労するかもしれませんインタラクティブである)の使用tkplotよりも印刷する変更のカップルを作っRコードは、RapidMiner外で動作させることができませんでした。

また、サンプルを再現可能にするために、コードに単純なデータを追加しました。

作成したpngファイルの場所を結果を保存する場所に変更します(RapidMinerは一時的なローカルフォルダを使用して、場所を明示する必要があります)。

rm_main = function(data) 
{ 
    data2 = matrix(c(1,2,3,1,2,1), nrow = 2, ncol = 3) 
    total_occurrence <- colSums(data2) 
    data_matrix <- as.matrix(data2) 
    co_occurrence <- t(data_matrix) %*% data_matrix 
    library(igraph) 
    graph <- graph.adjacency(co_occurrence, 
         weighted = TRUE, 
         mode="undirected", 
         diag = FALSE) 
    png('c:/temp/r-graph.png')      
    plot(graph, 
     vertex.label=names(data2), 
     vertex.size=total_occurrence*1, 
     edge.width=E(graph)$weight*1,) 
    dev.off() 
return(list(data)) 
} 
+0

ありがとう –