簡體   English   中英

R Shiny中的動態選擇輸入

[英]dynamic select input in R shiny

我試圖使用獨特的功能來創建selectInput選項。 但是,我的數據如下所示,這將需要多個映射。 例如,類似:

choices = c(`Pro Forma` = c('Pro-forma', 'ProForma', 'Proforma', 'Pro-Forma')`)

但不確定什么是正確的語法。

> unique(heatmap_raw$Status)
# [1] "Active"     "Redeeming"  "Proforma"   NA           "Pro-forma"  "ProForma" 
# [7] "na"         "40act"      "40 Act"     "Pro-Forma"  "40ACT"      "UCITS"   

selectInput("select month", label = ("Select Month"),
choices = c(unique(month(heatmap_raw$period))))

我認為您的問題是您的數據集未標准化。 如果您有一堆非標准狀態代碼,例如:

status <- c( "Active","Redeeming","Proforma",NA,"Pro-forma","ProForma","na",
             "40act","40 Act","Pro-Forma","40ACT","UCITS")  

我將它們的大小寫和標點標准化:

status <- tolower(gsub("\\W","",status))
# plus, do something for the NA vs. "na" status
status[is.na(status)] <- "na" # or something else, just to achieve consistency 

從干凈的數據開始將避免以后需要變通辦法。

暫無
暫無

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

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