简体   繁体   English

R中三个级别的下拉列表

[英]Drop-down list of three levels in R

I want do make a menu to selection schools. 我想做一个选校的菜单。 But the schools are nested in citys and this on departments so I need to this in a drop down list of three leves. 但是学校位于城市中,而学校又位于部门中,因此我需要在三个级别的下拉列表中进行选择。 This code works well for departments and citys. 此代码适用于部门和城市。 But when I expand for schools it gives me a error 但是当我扩展学校时,这给了我一个错误

Thanks 谢谢

require(shiny)

datas <- data.frame(directory = c(puntaje_2016_1$estu_reside_depto), file = c(puntaje_2016_1$estu_reside_mcpio) , cole = c(puntaje_2016_1$cole_nombre_sede) )


runApp(list(
  ui = basicPage(
    sidebarPanel(
      selectInput("directory", "Select a directory", choices = levels(datas$directory), selected = levels(datas$directory)[1]),
      tags$hr(),
      selectInput("files", "Select files", choices = datas$file[datas$directory == levels(datas$directory)[1]], multiple = FALSE)
     ## tags$hr()
      ##selectInput("cole", "Select files", choices = datas$cole[datas$file == levels(datas$file)[1]], multiple = FALSE)
          )
  ),
  server = function(input, output, session) {

observe({
  directory <- input$directory
  updateSelectInput(session, "files", choices = datas$file[datas$directory == directory])
      })
##observe({
  ##files<-input$files 
  ##updateSelectInput(session, "coles", choice = datas$cole[datas$file == ##files])
   ## })
  }
))

You don't have to do this: 您不必这样做:

datas$file[datas$directory == directory]

You can just do this: 您可以这样做:

unique(data$file$directory)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM