分析中,经常要进行条件筛选,常用的方法有:
1. 单选
output$Box_curve_cleaningOrNot = renderUI({
radioButtons(inputId = "curve_cleaning_or_not", label = "样本是否包含异常值",
choiceNames = c("去除异常值", "包含异常值"),
choiceValues = c("去除异常值", "包含异常值"), selected = "去除异常值")
})
2. 下拉菜单
output$Box_curve_level = renderUI({
selectInput(inputId = "curve_level", label = "选择车辆级别", c("所有", unique(car_data_58_index$car_level)), selected = "所有")
})
3. 输入条件
textInput("curve_series_text","请输入车系:以英文,隔开"),
方法1. 2 两种方法直接用 '==' 进行匹配即可
方法3 则要用的文本分割 unlist(strsplit(x, '[分隔符]'))
unlist(strsplit("a.b.c", "[.]"))
[1] "a" "b" "c"
数据集调用方法:
screen_series = reactive({
screen_province()[which(screen_province()$series_id %in%
unlist(strsplit(input$curve_series_text, "[,]")) & screen_province()$city_name == input$curve_city), ]
})
网友评论