【发布时间】:2019-12-03 23:28:44
【问题描述】:
我正在为一项为工人提供工资补贴的福利计划使用管理数据集。我正在尝试创建一个 Y 变量,其中 1 表示不再获得补贴的人,0 表示当前正在接受补贴的人,其中 end_date=NA。我将使用两个变量来执行此操作:1-start_date 和 2-end_date。
我尝试了以下代码,但收到一条错误消息:
train_worker_subsidy5_categorical_y = train_worker_subsidy5 %>%
mutate(left_welfare = numeric(is.na(end_date)))
test_worker_subsidy5_categorical_y = test_worker_subsidy5 %>%
mutate(left_welfare = numeric(is.na(end_date)))
错误信息是:
数字错误(is.na(end_date)):无效的“长度”参数
【问题讨论】:
-
查看
?numeric的帮助文件。您可能正在寻找as.numeric而不是numeric;后者并没有达到您的预期。