2

我有以下矩阵:

   Country Sp 
1 Portugal Cc 
2    Spain Cc 
3   France Cc 
4    Italy Cm 

如果我做:

selectInput("country", "Country:", choices=NestingArea$Country)

我会得到4个国家的名单。但是,如果我只想列出“Sp==Cc”的国家(葡萄牙、西班牙和法国),我应该怎么做?

4

1 回答 1

0
NestingArea <- data.frame(Country = c("Portugal", "Spain", "France", "Italy"),
                 Sp = c("Cc", "Cc", "Cc", "Cm"))

您可以获得所需的国家/地区子集:

NestingArea$Country[NestingArea$Sp == "Cc"]
#> [1] "Portugal" "Spain"    "France"

因此,解决方案是:

selectInput("country", "Country:", choices=NestingArea$Country[NestingArea$Sp == "Cc"])
于 2021-10-02T10:48:00.057 回答