2017-03-03 5 views
0

私の機能の使い方を簡単にするために少し光沢のあるアプリを設定したいと思っています。だから私は使いたい機能が光沢のあるファイルアップロード、機能に参加する

create_rating <- function(data_path, x, y, z) 

入力されString, int, int int 出力がmatrix

library(shiny) 
library(NLP) 

create_rating <- function(data_path, x, y, z){} 

ui <- fluidPage(

    titlePanel("Review"), 
    sidebarLayout(
    sidebarPanel(
     fileInput("file1", "Choose .txt File", 
       accept=c("text/csv", 
          "text/comma-separated-values,text/plain")), 
     actionButton("update", "Upload!"), 
     hr(), 

     numericInput("good", "3* Rating",15), 
     numericInput("ok", "2* Rating",8), 
     numericInput("bad", "1* Rating",3)  
    ), 
    mainPanel(
     h4("Review"), 
     tableOutput("result_shiny") 
    ) 
    ) 

) 

server <- function(input, output) { 
    inFile <- reactive({input$file1}) 
    if(is.null(inFile())) 
    return(NULL) 

    x <- reactive({input$good}) 
    y <- reactive({input$ok}) 
    z <- reactive({input$bad}) 

    result <- reactive({ 
     input$update 
     withProgress({ 
      setProgress(message = "Processing review...") 
      physical_check(as.String(path), x(), y(), z()) 
     }) 
     }) 

    output$result_shiny <- renderTable({result()}) 
} 
# Run the application 
shinyApp(ui = ui, server = server) 

であるそれからそれは、ウィンドウを開き、レイアウトフィットが、それは、処理通知のすべての時間を示しているといません結果。

またはI

server <- function(input, output) { 
     output$result_shiny <- eventReactive(input$update,{ 
     inFile <- reactive({input$file1}) 
     x <- reactive({input$good}) 
     y <- reactive({input$ok}) 
     z <- reactive({input$bad}) 
     resultat <- reactive({ 
     withProgress({ 
      setProgress(message = "Processing review...") 
      physical_check(as.String(inFile()$datapath), x(), y(), z()) 
     }) 
     }) 

    }) 

} 

のようなサーバーの一部を試みたが、この機能で、それはウィンドウを開き、私はまた、何も処理通知を、ファイルを選択していないアップロードボタンと何をプッシュすることができます。

ありがとうございます!

答えて

0

私はあること(私はあなたのコード内の任意の場所に定義されたそのような機能がないので、あなたが機能create_ratingないphysical_checkに言及されたと仮定しています)機能create_ratingように条件if(!is.null(inFile()))を追加して機能のサーバーの一部を変更しましたファイルがアップロードされた後でのみ呼び出されます。

server <- function(input, output) { 
    inFile <- reactive({input$file1}) 

    x <- reactive({input$good}) 
    y <- reactive({input$ok}) 
    z <- reactive({input$bad}) 
    observe({ 
    if(!is.null(inFile())){ 
     result <- reactive({ 
     input$update 
     withProgress({ 
      setProgress(message = "Processing review...") 
      create_rating(as.String(path), x(), y(), z()) 
     }) 
     }) 
     output$result_shiny <- renderTable({result()}) 
    } 

    }) 

} 

希望すると助かります!

+0

ありがとう、うまくいきます。私は確信が持てませんが、シャイニーがなぜ私の試みを受け入れていないのですか? –

関連する問題