如果我有以下数据框:
Hours<-c(2,3,4,2,1,1,3)
Project<-c("a","b","b","a","a","b","a")
cd=data.frame(Project,Hours)
以下Shiny代码有什么问题: 为什么我会收到错误:标记错误(&#34;表单&#34;,列表(...)):缺少参数,没有默认值
##server.R
library(shiny)
library(ggplot2)
library(lattice)
# Define shiny server
shinyServer(function(input, output) {
#Simple test plot
output$testPlot = renderPlot( {
pdata=subset(cd, Project==input$proj)
densityplot(pdata$Hours,lwd=3)
})
})
library(shiny)
ulist=levels(cd$Project)
names(ulist) = ulist
# Sidebar with a slider input for the number of bins
shinyUI(pageWithSidebar(
# Application title
headerPanel("Project Data"),
sidebarPanel(
#Which table do you want to view, based on the list of institution names?
selectInput("proj", "Project:",ulist),
),
# Show a plot of the generated distribution
mainPanel(
plotOutput("testPlot"),
)
) )
错误再次出现:标记错误(&#34;表单&#34;,列表(...)):缺少参数,没有默认值 这看起来很简单,但我不知道什么是错的。任何建议都将非常感激。
答案 0 :(得分:1)
您的ui.R
:
shinyUI(pageWithSidebar(
headerPanel("Project Data"),
sidebarPanel(
selectInput("proj", "Project:",ulist) # remove comma here
),
mainPanel(
plotOutput("testPlot") # remove comma here
)
) )
答案 1 :(得分:0)
我认为ui.R中有一些额外的逗号,即在selectInput和plotOutput命令之后