我对这一切都很陌生,正在制作一个简单的闪亮应用程序,通过水/电力消耗绘制收入和人口。我基本上想根据人口和收入水平绘制水/电力消耗量。我知道我的ui.R似乎没问题,问题是我对server.R的情节。试着让它尽可能简单
这是我的错误和代码。提前感谢所有帮助
Listening on http://127.0.0.1:6960
Warning in xy.coords(x, y, xlabel, ylabel, log) :
NAs introduced by coercion
Warning in xy.coords(x, y, xlabel, ylabel, log) :
NAs introduced by coercion
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 [/Users/****/server.R#12]
89: <reactive:plotObj>
78: plotObj
77: origRenderFunc
76: output$plot_data
1: runApp[enter image description here][1]
表示ui.R
ui.R
library(shiny)
shinyUI(fluidPage(
# Title
titlePanel("Los Angeles Water Usage"),
p("The main purpose of the Application is to dynamically represent the Water use in the City of Los Angeles based on different factors. Factors may include income level and area of residence. Income and Water consumption data was collected on FY 2015.", align="left"),
sidebarLayout(
sidebarPanel(
#Select Input for Charting Water or Power
selectInput("commodity", "Select Water or Power Consumption:",
choices = colnames(WaterPopulationIncome[4:5]), selected = "Water"),
#Sets the X axis variable
selectInput("xvar", "Select x-axis Variable",
choices = colnames(WaterPopulationIncome[2:3]), selected = "Total.Population"),
#Sets the Y axis variable
selectInput("yvar", "Select y-axis Variable",
choices = colnames(WaterPopulationIncome[2:3]), selected = "Median_Household_income"),
# Show a plot
mainPanel(
plotOutput("plot_data")
)
)
))
for server.R
library(shiny)
# Define server logic required to draw a histogram
shinyServer(function(input, output) {
#Scatter Plot
my_reactive <- reactive({
WaterPopulationIncome[sample(nrow(WaterPopulationIncome), input$commodity),]
})
output$plot_data <- renderPlot({
plot(my_reactive, x = input$xvar, y = input$yvar)
})
})
示例df
Zip Total.Population Median_Household_income Water.Use Power.Use place_geoid Median.Age Average.Household.Size Mean_income
90001 57110 33887 15.08 318 16000US0644000 26.6 4.4 42625
90001 57110 33887 14.03 352 16000US0644000 26.6 4.4 42625
90001 57110 33887 14.53 310 16000US0644000 26.6 4.4 42625
错误页面