我正在尝试使用unique函数来创建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))))
答案 0 :(得分:0)
我认为您的问题是您的数据集未规范化。如果您有许多非标准状态代码,例如:
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
从干净的数据开始将避免以后需要解决方法。