我有以下数据集作为R内的数据帧
article_number 1st_cutoff_date 2nd_cutoff_date
abc 12/01/2019 01/14/2020
def 02/10/2020 02/10/2020
我想要做的是在1st_cutoff_date == 2nd_cutoff_date,然后将2nd_cutoff日期替换为空白值“”的情况。因此,在第二种情况下,'def'则2nd_cutoff_date将为空“”
数据框是有因素的,并且有NA-我已转换为字符并尝试了以下操作:
AAR_FTW_Final_w_LL[AAR_FTW_Final_w_LL$`1st_Booking_Deadline` == AAR_FTW_Final_w_LL$`2nd_Booking_Deadline`,c("2nd_Booking_Deadline")] <- " "
&
ind<- AAR_FTW_Final_w_LL$`1st_Booking_Deadline` == AAR_FTW_Final_w_LL[`2nd_Booking_Deadlilne`]
AAR_FTW_Final_w_LL[ind,c("2nd_Booking_Deadline")] <- " "
均返回错误:
Error in AAR_FTW_Final_w_LL$`1st_Booking_Deadline` :
$ operator is invalid for atomic vectors
我尝试用[]替换$,但是随后出现错误,其中一列丢失。有没有更简单的方法可以执行此任务?