【发布时间】:2015-03-08 01:18:27
【问题描述】:
我是 R 新手,并尝试复制教程中的 barplot Shiny 示例(Link。但是,我遇到了一个错误。这是因为数据框的类型吗?我阅读了其他几个“xlim”错误页面, 并且似乎没有得到任何结果,因为它们主要用于非条形图示例。我已经以与示例相同的结构复制了数据框,这是我想要开始的地方。任何帮助将不胜感激。
Warning in min(w.l) : no non-missing arguments to min; returning Inf
Warning in max(w.r) : 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
Error in plot.window(xlim, ylim, log = log, ...) :
need finite 'xlim' values
df:
Name
Facility Atlanta Chicago Boston New York
Home 5 0 12 5
Post Acute 23 5 43 0
Relative 7 72 33 0
Hospital 18 34 19 67
服务器.R
library(shiny)
## Define where the data file exists
setwd("C:/Users/R")
## Name the object to hold csv
dta <- read.csv(file = "data.csv", na.strings =c("", "NA"))
## Assign new object as data frame and get column info
call <- data.frame(dta)
df <- table(call$Facility, call$name)
shinyServer(function(input, output){
# # Create the data frame to display
output$dcPlot <- renderPlot({
# Render a barplot
barplot(df[,input$name],
main=input$name,
ylab="Number of Discharges",
xlab="Discharge Type")
})
})
这里是 ui.R
# Bring in the library
library(shiny)
# Define the overall UI
shinyUI(
# Use a fluid Bootstrap layout
fluidPage(
# Give the page a title
titlePanel("Discharge by Provider"),
# Generate a row with a sidebar
sidebarLayout(
# Define the sidebar with one input
sidebarPanel(
selectInput(inputId = "Name",
label = "Name:",
choices=colnames(df)),
hr(),
## This input goes below the drop down bars
helpText("Data from Episode Connect monthly Call Forms")
),
# Create a spot for the barplot
mainPanel(
plotOutput("dcPlot")
)
)
)
)
【问题讨论】: