2017-03-03 2 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) 

입니다 있지만 처리 통지 모든 시간을 표시하고있다 결과.

또는 내가

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 (나는 코드에있는 정의 된 이러한 기능이 없기 때문에이 기능 create_rating를 참조하지 physical_check 있다고 가정하고) 할 수 있도록 조건 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

감사합니다. 잘하고 있습니다. 확실하지는 않지만 샤이니가 내 시도를 받아들이지 않는 이유는 무엇입니까? –

관련 문제