Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 选择R中的输入_Mysql_R_User Interface_Shiny - Fatal编程技术网

Mysql 选择R中的输入

Mysql 选择R中的输入,mysql,r,user-interface,shiny,Mysql,R,User Interface,Shiny,我想从Mysql查询中读取的列表中进行选择。我在代码中得到一个错误。我一定是做错了什么,但不知道是什么 我想从sql查询中读取的SKU列表中进行选择。我在ui部分得到一个错误 我甚至不确定这是否可行,但列出所有SKU将非常及时 我收到以下错误: 标记(“div”,列表(…)中出错: 缺少参数“sidebarPanel”,没有默认值 shinyApp(用户界面=用户界面,服务器=服务器) 有效错误(ui):找不到对象“ui” library('RMySQL') 图书馆(“plyr”) 库(‘闪亮’

我想从Mysql查询中读取的列表中进行选择。我在代码中得到一个错误。我一定是做错了什么,但不知道是什么

我想从sql查询中读取的SKU列表中进行选择。我在ui部分得到一个错误

我甚至不确定这是否可行,但列出所有SKU将非常及时

我收到以下错误:

标记(“div”,列表(…)中出错: 缺少参数“sidebarPanel”,没有默认值

shinyApp(用户界面=用户界面,服务器=服务器) 有效错误(ui):找不到对象“ui”

library('RMySQL')
图书馆(“plyr”)
库(‘闪亮’)
库('比例')
图书馆(shinyapps)
图书馆(GG2)

con您的
selectize=FALSE
附近有一个缺少括号,并且(正如@DavidRobinson所建议的)您需要一个头面板

代码修复

library(shiny)
library(ggplot2)
# con <- dbConnect(MySQL(), user="user", password="password",dbname="DB", host="host");
# rank<-dbGetQuery(con,"select sku from DB")
# for test hard coding the rank as I dont have your data
# test rank
rank$sku <- c(1,2,3)

#build a shiny app to select which sku to pick
server <- function(input, output) {
  output$distPlot <- renderPlot({
    hist(rnorm(input$obs), col = 'darkgray', border = 'white')
  })
}

ui <- pageWithSidebar(
  ## Application title

  # missing headerPanel
  headerPanel(title = "Hello"),

  # missing bracket after selectize
  sidebarPanel(
    sliderInput("obs", "Number of observations:", min = 10, max = 500, value = 100),
    selectInput(
      'e0', '0. An ordinary select input', choices = unique(rank$sku),
      selectize = FALSE) 
    ),

  mainPanel(plotOutput("distPlot"))    
)

shinyApp(ui = ui, server = server)
第二个结果

然后在第二个面板上

调试建议

这些
闪亮的
页面可以有很多括号,因此在编辑器中依次仔细选择括号,如RStudio,以确保括号匹配正常


祝你一切顺利

你犯了什么错误?(您是否可以在收到错误后发布
traceback()
的结果?标记(“div”,列表(…)中有错误:缺少参数“sidebarPanel”,没有默认值>>shinyApp(ui=ui,server=server)错误生效(ui):找不到对象“ui”
pageWithSidebar
需要一个headerPanel作为第一个参数。在
侧栏面板(
行)之前添加
headerPanel(“某些标题”),
。@megv,也更新你的RStudio!0.99链正在使用自动完成功能改进编辑器,这样你就不会再遇到这种情况了-“对于闪亮的应用程序,ui.R+server.R对的自动完成”。
library(shiny)
library(ggplot2)
# con <- dbConnect(MySQL(), user="user", password="password",dbname="DB", host="host");
# rank<-dbGetQuery(con,"select sku from DB")
# for test hard coding the rank as I dont have your data
# test rank
rank$sku <- c(1,2,3)

#build a shiny app to select which sku to pick
server <- function(input, output) {
  output$distPlot <- renderPlot({
    hist(rnorm(input$obs), col = 'darkgray', border = 'white')
  })
}

ui <- pageWithSidebar(
  ## Application title

  # missing headerPanel
  headerPanel(title = "Hello"),

  # missing bracket after selectize
  sidebarPanel(
    sliderInput("obs", "Number of observations:", min = 10, max = 500, value = 100),
    selectInput(
      'e0', '0. An ordinary select input', choices = unique(rank$sku),
      selectize = FALSE) 
    ),

  mainPanel(plotOutput("distPlot"))    
)

shinyApp(ui = ui, server = server)
# navbar tabbed page example - without headerPanel
ui2 <- navbarPage(title = "Hello Another Style", 
           tabPanel("Chart Panel",
                    sidebarLayout(
                      sidebarPanel(
                        sliderInput("obs", "Number of observations:", 
                                    min = 10, max = 500, value = 100),
                        selectInput(
                          'e0', '0. An ordinary select input', 
                          choices = unique(rank$sku),
                          selectize = FALSE)
                        ),
                      mainPanel(
                        plotOutput("distPlot")
                      )
                    )
           ),
           tabPanel("Instructions",
                    mainPanel(
                       p("Notes here for example...")
                    )
           )        

)