Shiny/server.R

#http://www.randpy.tokyo/entry/shiny_16


source("calcor.R")

server <- function(input, output, session) {
  observeEvent(input$file, {

    csv_file <- reactive(read.csv(input$file$datapath))
    output$table <- renderTable({head(csv_file(), n = 30)})

    output$colname<- renderUI({
      selectInput("y", "評価対象", colnames(csv_file()))
    })
  })

  observeEvent(input$submit, {
    #ファイルの読み込み
    csv_file <- reactive(read.csv(input$file$datapath))

    #解析本体
    result <- reactive(calcor(as.formula(paste0(input$y, "~.")), csv_file()))

    #p値の表作成
    psort_result <- reactive(psort(result()))

    #表を表示
    output$plist <- renderTable({psort_result()})

    #選択項目
    output$plotname<- renderUI({
      selectInput("x", "相関確認(p値昇順)", as.vector(psort_result()$name))
    })

    output$plot <- renderPlot({slideshow(result(), name = input$x, cex = 1)} )
  })


  # Close the app when the session completes
  session$onSessionEnded(function() {
    stopApp()
    q("no")
  })


}
ToshihiroIguchi/calcor documentation built on May 12, 2019, 1:08 p.m.