CSS   发布时间:2022-04-17  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了闪亮的ui.R – 标签中的错误(“div”,列表(…)) – 不知道错误在哪里大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
更新 – 12/17/2012 9am CDT:示例已更新演示数据和完整代码. [/更新].

示例数据https://gist.github.com/4318774

描述:
我一直在玩新的Shiny包(喜欢它),但是还没有明白当我运行appApp(“”)时会发生错误.错误是标记错误(“div”,list(…)):缺少参数.

我正在尝试创建一个交互式网络应用程序,用于图形化的人口统计数据.我使用以下作为指南:
https://gist.github.com/4026749
http://rstudio.github.com/shiny/tutorial/

与选项(错误=恢复),我得到:

Listening on port 8100
Error in tag("div",list(...)) : argument is missing,with no default

Enter a frame number,or 0 to exit   

 1: runApp("//~~my app~~")
 2: tryCatch(while (true) {
    serviceApp(ws_env)
},finally = {
    timerCallBACks$clear()
    websocket_close(ws_env)
})
 3: tryCatchList(expr,classes,parentenv,handlers)
 4: serviceApp(ws_env)
 5: service(server = ws_env,timeout = timeout)
 6: server$static(j,J$wsinfo)
 7: handler(ws,header)
 8: handler(ws,header)
 9: local({
    cachecontext$with(function() {
        source(filePath,local = new.env(parent = .GlobalEnv))
    })
})
10: eval.parent(substitute(eval(quote(expr),envir)))
11: eval(expr,p)
12: eval(expr,envir,enclos)
13: eval(quote({
    cachecontext$with(function() {
        source(filePath,local = new.env(parent = .GlobalEnv))
    })

14: eval(expr,enclos)
15: cachecontext$with(function() {
    source(filePath,local = new.env(parent = .GlobalEnv))
})
16: func()
17: source(filePath,local = new.env(parent = .GlobalEnv))
18: withVisible(eval(ei,envir))
19: eval(ei,envir)
20: eval(expr,enclos)
21: ui.R#6: shinyUI(pageWithSidebar(headerPanel("Demographics Web Demo - Eglin Data"),sidebarPanel(texTinput("plot.ti
22: force(ui)
23: pageWithSidebar(headerPanel("Demographics Web Demo - Eglin Data"),sidebarPanel(texTinput("plot.title","title:",24: bootstrapPage(div(class = "container-fluid",div(class = "row-fluid",headerPanel),sideb
25: tagList(importBootstrap(),list(...))
26: div(class = "container-fluid",sidebarPanel,mainP
27: tags$div(...)
28: tag("div",list(...))
29: div(class = "row-fluid",mainPanel)
30: tags$div(...)
31: tag("div",list(...))
32: sidebarPanel(texTinput("plot.title","Population Pyramid of Members"),wellPanel(p(strong("Demographic o
33: div(class = "span4",tags$form(class = "well",...))
34: tags$div(...)
35: tag("div",list(...))
36: tags$form(class = "well",...)
37: tag("form",list(...))
38: wellPanel(p(strong("Demographic of Interest")),checkboxInput(inputId = "age_dist",label = "Age DiStribution",va
39: div(class = "well",...)
40: tags$div(...)
41: tag("div",list(...))

我尝试调查发生了什么,但是checkboxInput使代码看起来很准确.它也是Rstudio(github linked abovE)上的“股票”示例的直接副本

ui.R / Server.R代码:
ui.R

library(shiny)

shinyUI(pageWithSidebar(
  # application title
  headerPanel("Demographics Web Demo - Eglin Data"),# sidebar with controls to allow user to define graphical elements and how
  # they want them displayed.
  sidebarPanel(
    # allow the user to write a plot title
    texTinput("plot.title",# allow the user to determine which demographic they want to plot
    wellPanel(
      p(strong("Demographic of Interest")),value = TRUE),checkboxInput(inputId = "wealth_dist",label = "Household Wealth",value = falSE),checkboxInput(inputId = "home_val",label = "Home Value",checkboxInput(inputId = "ed_level",label = "Members' Education",checkboxInput(inputId = "inc_level",label = "Members' Est. Income",checkboxInput(inputId = "h_own",label = "Homeownership",),# allow the user to determine age-bracket size. Input used in plotTing
    sliderInput("age_cut","SELEct Size of Age Brackets:",min= 3,max= 20,value= 5),# allow the user to subset their demographics by age range
    #sliderInput("age_sub","Please SELEct the age range @R_616_8337@ould like to 'zoom-in' on:",#            min= 0,max= 120,value= c(15,65)),# display the appropriate graphics based on the user SELEctions defined 
  # above.
  mainPanel(
    h3(textOutput("caption")),conditionalPanel(condition= "input.age_dist",plotOutput(outputId= "plot_age")),conditionalPanel(condition= "input.wealth_dist",plotOutput(outputId= "plot_wealth")),conditionalPanel(condition= "input.home_val",plotOutput(outputId= "plot_home_value")),conditionalPanel(condition= "input.ed_level",plotOutput(outputId= "plot_edu")),conditionalPanel(condition= "input.inc_level",plotOutput(outputId= "plot_inc")),conditionalPanel(condition= "input.h_own",plotOutput(outputId= "plot_h_own"))
  )
))

server.R

# require packages
if (!require(ggplot2)) {
  stop("This application requires ggplot2. To install it,please run 'install.packages(\"ggplot2\")'.\n")
}
if (!require(plotriX)) {
  stop("This application requires plotrix. To install it,please run 'install.packages(\"plotrix\")'.\n")
}
library(shiny)

# load example demo data
load("~~you'll need to load the test data here")


shinyServer(function(input,output) {

  # reactive function based on user input for plot title
  # This function is automatically called to update the display
  output$caption <- reactiveText(function() {
    input$plot.title
  })

  updateAge_f <- reactive(function() {
    # re-define age brackets based on user input
    demos$age_f <- ordered(cut(demos$age,breaks= c(seq(0,max(demos$agE),input$age_cut)),include.loWest= T))
  })

  # Generate a plot of the Members' age diStribution
  output$plot_age <- reactivePlot(function() { 
    # call to update age factor if needed
    updateAge_f()
    # develop input vectors
    male <- as.vector(table(demos$age_f,demos$female_flag)[,1]/sumMary(demos$female_flag)[1] * 100)
    women <- as.vector(table(demos$age_f,2]/sumMary(demos$female_flag)[2] * 100)
    # create plot
    pyramid.plot(lx= male,rx= women,labels= levels(demos$age_f),lxcol= "blue",rxcol= "pink",main= "Population Pyramid of Members",gap= 2,labelcex= .75)
  })

  # generate a plot of members' wealth codes
  output$plot_wealth <- reactivePlot(function() { 
    # call to update age factor if needed
    updateAge_f()

    if (input$factor_age == TRUE) {
      ggplot(demos2,aes(wealth)) + geom_bar() + 
        faCET_wrap(~ age_f,ncol= 3) + theme_bw() +
        labs(title= "Wealth of Members by Age Bracket",y= "Count of Individuals",x= "Decile of Wealth (by StatE)") +
        theme(axis.text.x= element_text(angle= 90))
    } else if (input$factor_age == falSE) {
      ggplot(demos2,aes(wealth)) + geom_bar() + 
        theme_bw() +
        labs(title= "Wealth of Members of your Members",x= "Decile of Wealth (by StatE)") +
        theme(axis.text.x= element_text(angle= 90))
    }
  })

  # generate a plot of home value of members' properties
  output$plot_home_value <- reactivePlot(function() { 
    # call to update age factor if needed
    updateAge_f()

    if (input$factor_age == TRUE) {
      ggplot(demos2,aes(home_value)) + geom_bar() + 
        faCET_wrap(~ age_f,ncol= 3) + theme_bw() +
        labs(title= "Home Value by Age Bracket",x= "Home Value") +
        theme(axis.text.x= element_text(angle= 90))
    } else if (input$factor_age == falSE) {
      ggplot(demos2,aes(home_value)) + geom_bar() + 
        theme_bw() +
        labs(title= "Home Value of your Members",x= "Home Value") +
        theme(axis.text.x= element_text(angle= 90))
    }
  })

  # generate a plot of education diStribution
  output$plot_edu <- reactivePlot(function() { 
    # call to update age factor if needed
    updateAge_f()

    if (input$factor_age == TRUE) {
      ggplot(demos2,aes(ed_codE)) + geom_bar() + 
        faCET_wrap(~ age_f,ncol= 3) + theme_bw() +
        labs(title= "Education Level by Age Bracket",x= "Education Level") +
        theme(axis.text.x= element_text(angle= 90))
    } else if (input$factor_age == falSE) {
      ggplot(demos2,aes(ed_codE)) + geom_bar() + 
        theme_bw() +
        labs(title= "Education Level of your Members",x= "Education Level") +
        theme(axis.text.x= element_text(angle= 90))
    }
  })

  # generate a plot of members' estimated income levels
  output$plot_inc <- reactivePlot(function() { 
    # call to update age factor if needed
    updateAge_f()

    if (input$factor_age == TRUE) {
      ggplot(demos2,aes(inC)) + geom_bar() + 
        faCET_wrap(~ age_f,ncol= 3) + theme_bw() +
        labs(title= "Estimated Income by Age Bracket",x= "Estimated Income Range") +
        theme(axis.text.x= element_text(angle= 90))
    } else if (input$factor_age == falSE) {
      ggplot(demos2,aes(inC)) + geom_bar() + 
        theme_bw() +
        labs(title= "Estimated Income of your Members",x= "Estimated Income Range") +
        theme(axis.text.x= element_text(angle= 90))
    }
  })

  # generate a plot of members' homeownership
  output$plot_h_own <- reactivePlot(function() { 
    # call to update age factor if needed
    updateAge_f()

    if (input$factor_age == TRUE) {
      ggplot(demos2,aes(homeowner)) + geom_bar() + 
        faCET_wrap(~ age_f,ncol= 3) + theme_bw() +
        labs(title= "Home ownership by Age Bracket",x= "Home owner / Renter") +
        theme(axis.text.x= element_text(angle= 90))
    } else if (input$factor_age == falSE) {
      ggplot(demos2,aes(homeowner)) + geom_bar() + 
        theme_bw() +
        labs(title= "Home ownership of your Members",x= "Home owner / Renter") +
        theme(axis.text.x= element_text(angle= 90))
    }
  })
})

任何帮助将不胜感激,仍然试图学习闪亮(像其他人).

解决方法

在ui.R中,您不应该在此行末尾加上逗号:
sliderInput("age_cut",

此行末尾也不应有逗号

checkboxInput(inputId = "h_own",

一般来说,您不应该在一个部分的最后一个组件之后有一个逗号.就像任何R函数一样,你通常不会用逗号结束函数调用.例如sum(5,)给出错误.

大佬总结

以上是大佬教程为你收集整理的闪亮的ui.R – 标签中的错误(“div”,列表(…)) – 不知道错误在哪里全部内容,希望文章能够帮你解决闪亮的ui.R – 标签中的错误(“div”,列表(…)) – 不知道错误在哪里所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。