2017-06-01 11 views
1

これは私のコードは配管工を介してRで複数のプロットを返すにはどうすればよいですか?

library(plumber) 
    data(mtcars) 
    test=mtcars 
    #' @get /graph 
    #' @png 
    makePlot <- function(){ 
     par(mfrow=c(2,1)) 
     hist(test$mpg) 
     hist(test$wt) 
    } 

    r <- plumb("plum_api.R") 
    r$run(port=8000) 

のように見えますが、出力には、私は唯一の1つのグラフを見るものです。

+0

コードは再現できません。 'mpg'の代わりに' mtcars'データセットを使うのですか? –

+0

@AdamQuekええ、訂正しました! –

答えて

0

これは問題の解決策ではなく、上記のコードの個人的なテストです。
私は次のコードでファイルmyfile.R作成:

# myfile.R 

#* @get /graph 
#* @png 
makePlot <- function(){ 
     data(mtcars) 
     test=mtcars 
     par(mfrow=c(2,1)) 
     hist(test$mpg) 
     hist(test$wt) 
} 

をしてから、私はR内で次のコマンドを実行しました:

r <- plumb("myfile.R") 
r$run(port=8000) 

をこれは私がブラウザから得たものである:

enter image description here

希望すると、これが役立ちます。

関連する問題