2016-04-06 17 views
0

ユーザーがcsvファイルをアップロードし、ユーザーが選択した列に基づいて、光沢のあるアプリケーションを作成しようとしています。私が列xvとyvを選択すると、モデルを構築するためにデータフレームから値が取り込まれないように見えます。私は最小限の例を提示しなければならないことに気がついていますが、私は光沢があり、問題がどこにあるのかは分かりません。次のコード全体は、どんな助けでも大歓迎です。光沢のあるアプリケーションを使用してモデルを構築できません

これはコードです:コンソール上

library(shiny) 
library(shinydashboard) 
library(leaflet) 
library(data.table) 
library(ggplot2) 
library(usl) 

ui <- pageWithSidebar(
    headerPanel("CSV Viewer"), 
    sidebarPanel(
    fileInput('file1', 'Choose CSV File', 
       accept=c('text/csv','text/comma-separated-values,text/plain','.csv')), 
    tags$hr(), 
    checkboxInput('header', 'Header', TRUE), 
    fluidRow(
     column(6,radioButtons("xaxisGrp","X-Axis:", c("1"="1","2"="2"))), 
     column(6,checkboxGroupInput("yaxisGrp","Y-axis:", c("1"="1","2"="2"))) 
    ), 
    radioButtons('sep', 'Separator', 
       c(Comma=',', Semicolon=';',Tab='\t'), ','), 
    radioButtons('quote', 'Quote', 
       c(None='','Double Quote'='"','Single Quote'="'"),'"'), 
    uiOutput("choose_columns") 
), 
    mainPanel(
    tabsetPanel(
     tabPanel("Data", tableOutput('contents')), 
     tabPanel("Plot",plotOutput("plot")), 
     tabPanel("Summary",uiOutput("summary")) 

    ) 
) 
) 


####server 

server <- function(input, output,session) { 
    dsnames <- c() 
    u<- 
    data_set <- reactive({ 
    inFile <- input$file1 
    data(specsdm91) 
    if (is.null(inFile)) 
     return(specsdm91) 

    data_set<-read.csv(inFile$datapath, header=input$header, 
         sep=input$sep, quote=input$quote) 
    }) 

    output$contents <- renderTable({data_set()}) 

    observe({ 
    dsnames <- names(data_set()) 
    cb_options <- list() 
    cb_options[ dsnames] <- dsnames 
    updateRadioButtons(session, "xaxisGrp", 
         label = "X-Axis", 
         choices = cb_options, 
         selected = "") 
    updateCheckboxGroupInput(session, "yaxisGrp", 
          label = "Y-Axis", 
          choices = cb_options, 
          selected = "") 
    }) 
    output$choose_dataset <- renderUI({ 
    selectInput("dataset", "Data set", as.list(data_sets)) 
    }) 

    usl.model <- reactive({ 

     df <- data_set() 
    # print(df) 
     gp <- NULL 
     if (!is.null(df)){ 

     xv <- input$xaxisGrp 
     yv <- input$yaxisGrp 
     print(xv) 
     print(yv) 
     if (!is.null(xv) & !is.null(yv)){ 

      if (sum(xv %in% names(df))>0){ # supress error when changing files 

      usl.model <- usl(as.formula(paste(yv, '~', xv)), data = df) 

      } 
     } 
     } 
     return(gp) 
    } 
) 


    ##plot 
    output$plot = renderPlot({ 

    plot(usl.model()) 

}) 

    ## 
# output$summary <- renderUI({ 

    # summary(usl.model()) 

    #}) 

    ## 

    output$choose_columns <- renderUI({ 

    if(is.null(input$dataset)) 
     return() 
    colnames <- names(contents) 
    checkboxGroupInput("columns", "Choose columns", 
         choices = colnames, 
         selected = colnames) 
    }) 
} 
shinyApp(ui, server) 

======

エラー:あなたが返され、usl.modelでの反応:

Warning in min(x) : no non-missing arguments to min; returning Inf 
Warning in max(x) : no non-missing arguments to max; returning -Inf 
Warning in min(x) : no non-missing arguments to min; returning Inf 
Warning in max(x) : no non-missing arguments to max; returning -Inf 
Warning: Error in plot.window: need finite 'xlim' values 
Stack trace (innermost first): 
    81: plot.window 
    80: localWindow 
    79: plot.default 
    78: plot 
    77: plot 
    76: renderPlot [C:\shiny\file/ui.R#98] 
    68: output$plot 
    1: shiny::runApp 
+0

[どのように光沢のあるcsvファイルからモデルを作成しますか?](http://stackoverflow.com/questions/36431158/how-do-you-create-a-model-from-a-csv -file-in-shiny) – JohnSG

答えて

0

エラーがによるものですgpですが、usl.modelを返す必要があります。

関連する問題