R Shiny 需要有限的 'xlim' 值
Need finite 'xlim' values for R Shiny
我是 R 的新手,我尝试从教程中复制 barplot Shiny 示例 (Link。但是,我收到一个错误。这是因为数据帧的类型吗?我读了其他几个 'xlim' 错误页面,并且似乎没有得到任何地方,因为它们主要用于非 barplot 示例。我已经以与示例相同的结构复制了数据框,这是我想开始的地方。任何帮助都是非常感谢。
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
server.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")
)
)
)
)
您收到此错误是因为 table
函数的输出不是数据帧,而是 table
.
尝试:
df <- as.data.frame(unclass(table(call$Facility, call$name)))
此外,在您的 server.R
中,当您获取 input
数据时有错字,inputId
在您的 ui.R
[= 中是 Name
18=]
我是 R 的新手,我尝试从教程中复制 barplot Shiny 示例 (Link。但是,我收到一个错误。这是因为数据帧的类型吗?我读了其他几个 'xlim' 错误页面,并且似乎没有得到任何地方,因为它们主要用于非 barplot 示例。我已经以与示例相同的结构复制了数据框,这是我想开始的地方。任何帮助都是非常感谢。
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
server.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")
)
)
)
)
您收到此错误是因为 table
函数的输出不是数据帧,而是 table
.
尝试:
df <- as.data.frame(unclass(table(call$Facility, call$name)))
此外,在您的 server.R
中,当您获取 input
数据时有错字,inputId
在您的 ui.R
[= 中是 Name
18=]