Ich versuche, eine glänzende App zu erstellen, wo Benutzer eine CSV-Datei hochladen und basierend auf Benutzer ausgewählt Spalten, glänzende App Modell erstellen, zeigen Sie die Handlung des Modells und Zusammenfassung. Es sieht so aus, als wenn ich die Spalten xv und yv auswählen würde, werden Werte aus dem Datenrahmen nicht aufgefüllt, um das Modell zu erstellen. Ich merke, dass ich ein minimales Beispiel geben muss, aber ich bin sehr neu zu glänzend und weiß wirklich nicht, wo das Problem sein kann. Das Folgende ist der ganze Code, jede Hilfe wird sehr geschätzt.nicht in der Lage, ein Modell mit einer glänzenden Anwendung zu erstellen
Dies ist der Code:
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)
======
Fehler auf der Konsole:
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
Mögliche Duplikate von [wie erstellen Sie ein Modell aus einer CSV-Datei in glänzend] (http://stackoverflow.com/questions/36431158/how-do-you-create-a-model-from-a-csv -file-in-glänzend – JohnSG