Delete all rows coresponding to given ID

前端 未结 3 896
别跟我提以往
别跟我提以往 2021-01-27 06:21

Data overview:

> str(dataStart[c(\"gvkey\",\"DEF\",\"FittedRob\",\"NewCol\")])
\'data.frame\':   1000 obs. of  4 variables:
$ gvkey         : int  1004 1004          


        
3条回答
  •  无人共我
    2021-01-27 07:02

    You first have to select all gvkey's you want to delete:

    keys_to_delete <- unique(NewDataFrame$gvkey[NewDataFrame$NewCol %in% 
        c("Del","Del2")])
    

    And then use these to delete the corresponding rows:

    dataStart <- NewDataFrame[!(NewDataFrame$gvkey %in% keys_to_delete), ]
    

提交回复
热议问题