簡體   English   中英

R Shiny-如何將value和name屬性放在checkboxInput中?

[英]R Shiny - how to put value and name attributes in checkboxInput?

我發現RShiny很難使用,因為我無法控制自己的html,例如,

我想在下面創建一個復選框,

<input type="checkbox" id="species" name="species_particles" value="particles"/>

在我閃亮的ui.R中,

checkboxInput(inputId = "species",
                    label = "Particles",
                    value = "particles")

我得到這個錯誤,

ERROR: invalid 'y' type in 'x && y'

我不知道這意味着什么以及如何解決。 這是沒有道理的。 什么呀 什么x?

那名字屬性呢? 如何將其放在checkboxInput()

value的參數必須是邏輯參數,並確定是否默認選中該復選框。 例如,

checkboxInput(inputId = "species",
                label = "Particles",
                value = TRUE)

有關詳細信息,請參見?checkboxInput

該線程有些舊,但是由於尚未接受任何答案,因此要為復選框分配值,只需使用checkboxGroupInput而不是checkboxInput

library("shiny")

runApp(list(
    ## ui.R
    ui = shinyUI(
        fluidPage(
            checkboxGroupInput(
                inputId = "species"
                , label = "Particeles"
                , choices = c("Quarks" = "Quarks", "Leptons" = "Leptons"
                , "Antiquarks" = "Antileptons"))
            , uiOutput("tmp")
        )
    )
    ## server.R
    , server = function (input, output, session) {
        output$tmp <- renderUI({
            HTML(paste("Currently selected:", 
                paste(input$species, collapse = ", ")))
        })
    }
))

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM