或/ | R中的陈述

时间:2014-04-02 08:11:23

标签: r

Belows是我选择属性的代码"航空公司"等于" CX"," GA"," HX"或" RI"仅

Result <- Result[which(Result$Airline == "CX" | Result$Airline == "GA" | 
                         Result$Airline == "HX" | Result$Airline == "RI"),]

我想问一下R中是否有类似OR(Result$Airline, c("CX","GA","HX","RI"))的内容?

感谢您的温和帮助。

1 个答案:

答案 0 :(得分:3)

尝试:

Result <- Result[which(Result$Airline %in% c( "CX","GA","HX","RI"),]