R 使用ifelse()但不使用I';我一次只能选择一个条件

R 使用ifelse()但不使用I';我一次只能选择一个条件,r,R,我的数据集是: state soc_em_support CA 20 OR 22 WA 19 NV 12 我正在尝试创建以下内容: state soc_em_support Pacific CA 20 1 OR 22 1 WA 19 1 NV 12 0 我试过: county_test$pa

我的数据集是:

state   soc_em_support
CA      20
OR      22
WA      19
NV      12
我正在尝试创建以下内容:

state   soc_em_support   Pacific
CA      20               1
OR      22               1
WA      19               1
NV      12               0
我试过:

county_test$pacific <- ifelse(county_test$state==c("CA", "WA", "OR"), 1, 0)

country\u test$pacific在%
中使用
%,即
country\u test$pacific

Error: unexpected numeric constant in "county_test$pacific <- ifelse(county_test$state==c("CA", "OR") 1"