Ich bin ziemlich neu in diesem, so gibt es wahrscheinlich eine einfache Erklärung. Ich arbeite mit einem Datensatz von Wasserqualitätsbeobachtungen. Es beginnt wieFehler beim Bau Plot mit Shiny
Sample.ID,Sample.Date,Beach.Name,Sample.Location,Results,Units
050514CP13,5/5/2014,MIDLAND BEACH,Center,20,MPN/100 ml
062011GR04,6/20/2011,MANHATTAN BEACH,Left,0,MPN/100 ml
072808BH09,7/28/2008,MIDLAND BEACH,Right,28,MPN/100 ml
051214CP36,5/12/2014,SOUTH BEACH,Right,4,MPN/100 ml
081511KB07,8/15/2011,CEDAR GROVE,Left,360,MPN/100 ml
062909KB01,6/29/2009,MANHATTAN BEACH,Left,8,MPN/100 ml
082112KB07,8/21/2012,CEDAR GROVE,Left,20,MPN/100 ml
Ich habe folgendes ui.R
library(shiny)
beaches <- read.csv("BeachWaterQuality.csv", header = TRUE)
beachNames <- levels(beaches$Beach.Name)
new.date <- strptime(beaches$Sample.Date, format="%m/%d/%Y")
minDate <- min(new.date)
maxDate <- max(new.date)
shinyUI(fluidPage(
# Application title
titlePanel("Beach Water Quality History"),
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
selectInput("beach",
label = "Choose a beach to display",
choices = beachNames),
selectInput("sampleLocation",
label = "Choose a sample location",
choices = list("LEFT","CENTER", "RIGHT"),
selected="CENTER"),
dateRangeInput("dates",
label= "Choose a date range to display",
start=minDate,
end=maxDate)
),
# Show a plot of the selected data
mainPanel(
plotOutput("beachDataPlot")
)
)
))
Und das server.R
library(shiny)
shinyServer(function(input, output) {
beaches <- read.csv("BeachWaterQuality.csv", header = TRUE)
beaches$Results[is.na(beaches$Results)] <- 0
beachNames <- levels(beaches$Beach.Name)
new.date <- strptime(beaches$Sample.Date, format="%m/%d/%Y")
beaches <- cbind(beaches,new.date)
output$beachDataPlot <- renderPlot({
plotData <- subset(beaches, Beach.Name==input$beach & Sample.Location==input$sampleLocation)
plot(x=plotData$new.date,
y=plotData$Results,
xlab="Date",
ylab="Bacterial Count",
pch=16,
main=paste("Bacterial Count for",input$beach,input$sampleLocation))
lines(plotData$new.date,plotData$Results,col="red")
})
})
Wenn ich versuche, dies betreibe ich einen Fehler in der App bekommen Fenster das sagt
Error: need finite 'xlim' values
Und in t er 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):
103: plot.window
102: localWindow
101: plot.default
100: plot
99: renderPlot [C:\Users\jerem\YuckyBeach/server.R#30]
89: <reactive:plotObj>
78: plotObj
77: origRenderFunc
76: output$beachDataPlot
1: runApp
Kann jemand darauf hinweisen, was ich hier falsch mache?
Wie groß ist die Anzahl von 'plotData' Zeilen? Ist es 0? Ich habe ähnliche Fehler mit den folgenden Codes: 'plotData <- Teilmenge (Strände, Beach.Name ==" SOUTH BEACH "& Sample.Location ==" Left ")' dann 'plot (x = plotData $ new.date, y = plotData $ Results) ' – kitman0804