第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

conditionalPanel() 基于包含字符串中的邏輯

conditionalPanel() 基于包含字符串中的邏輯

明月笑刀無情 2022-08-18 15:59:35
我的詢問感覺接近于這個問題,但所提供的支持僅限于應用于一個數(shù)據(jù)元素的邏輯。我想學習JavaScript應用于字符串/向量/數(shù)組(不確定在我的示例中使用哪種語言),這樣如果選擇了任何哺乳動物,就會出現(xiàn)消息,但是如果選擇了任何鳥類,則不會出現(xiàn)消息。library(shiny)birds <- c("finch","robin","crow","duck")mammals <- c("elephant", "human", "dog", 'cat')ui <- fluidPage(   titlePanel("Select Conditional"),     mainPanel(       column(4,       selectizeInput(inputId = "animals",                      label = "Select An Animal",                      choices= list('Examples of Birds' = birds,                                     'Example of mammals' = mammals)       )),       column(8,       conditionalPanel(condition = "input.animals.indexOf('birds')",       textOutput("text")))     ))server <- function(input, output) {      output$text <- renderText({"This is a mammal."})}shinyApp(ui = ui, server = server)我嘗試過conditionalPanel(condition = "input.animals.Array.indexOf('birds')",conditionalPanel(condition = "input.animals.str.indexOf('birds')"conditionalPanel(condition = "input.animals.Vector.indexOf('birds')"conditionalPanel(condition = "input.animals.String.indexOf('birds')"感謝您的任何想法。請原諒我對向量,數(shù)組,字符串缺乏了解。
查看完整描述

1 回答

?
HUWWW

TA貢獻1874條經(jīng)驗 獲得超12個贊

R中的非輸入變量不會傳遞給JavaScript,作為一種解決方法,我將字符向量構建到JS數(shù)組中,并將其傳遞到條件中。因此,在這種情況下通過的實際條件是哪個執(zhí)行您想要的操作。['elephant', 'human', 'dog', 'cat'].includes(input.animals)


library(shiny)


birds <- c("finch","robin","crow","duck")

mammals <- c("elephant", "human", "dog", 'cat')


ui <- fluidPage(

  titlePanel("Select Conditional"),

  mainPanel(

    column(4,

           selectizeInput(inputId = "animals",

                          label = "Select An Animal",

                          choices= list('Examples of Birds' = birds, 

                                        'Example of mammals' = mammals)

           )),

    column(8,

           conditionalPanel(condition = paste0(paste0("[",toString(paste0("'",mammals,"'")),"]"),".includes(input.animals)"),

                            textOutput("text")))

  ))


server <- function(input, output) {

  output$text <- renderText({"This is a mammal."})

}


shinyApp(ui = ui, server = server)


查看完整回答
反對 回復 2022-08-18
  • 1 回答
  • 0 關注
  • 109 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號