运行简单的Shiny应用程序时出错

时间:2016-03-08 19:54:21

标签: r shiny

我正在尝试运行一个简单的Shiny App,它需要几个文本输入来生成一个SQL语句。当我取消注释textInput控件时,我不断收到以下错误。

match.arg(position)中的错误:'arg'必须为NULL或字符向量

我正在运行的代码是: 的 ui.R

library(shiny)

shinyUI(fluidPage(

 # Application title
 titlePanel("SQL Developer"),

 # Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
  sliderInput("topnrows",
              "Number of rows to show:",
              min = 1,
              max = 100,
              value = 50)
),

textInput("text1", label = "Text input", value = "Enter text..."),
# textInput("dbName",
#           label="Enter the Database Name",
#           value="Enter Database Name"),
# textInput("tableName",
#           "Enter the Table Name"),


# Show a plot of the generated distribution
mainPanel(
 h3( textOutput("sqlText"))
)
)
))

server.R     库(有光泽)

shinyServer(function(input, output) {


 output$sqlText <- renderPrint({


 paste("select top ", input$topnrows, " * from trial.table",sep='')
 })

 })

评论textInput()行,我可以运行该应用程序。我无法弄清楚我在textInput函数中缺少什么来显示错误。非常感谢任何帮助。

1 个答案:

答案 0 :(得分:0)

我认为您希望将所有输​​入都放在sidebarPanel()

shinyUI(fluidPage(

        # Application title
        titlePanel("SQL Developer"),

        # Sidebar with a slider input for number of bins
        sidebarLayout(
                sidebarPanel(
                        sliderInput("topnrows",
                                    "Number of rows to show:",
                                    min = 1,
                                    max = 100,
                                    value = 50),
                 textInput("dbName",
                           label="Enter the Database Name",
                           value="Enter Database Name"),
                 textInput("tableName",
                           label="Enter the Database Name",
                           value="Enter the Table Name"),
                textInput("text1", label = "Text input", value = "Enter text...")
        )                
                ,


                # Show a plot of the generated distribution
                mainPanel(
                        h3( textOutput("sqlText"))
                ))

))