Data overview:
> str(dataStart[c(\"gvkey\",\"DEF\",\"FittedRob\",\"NewCol\")]) \'data.frame\': 1000 obs. of 4 variables: $ gvkey : int 1004 1004
You first have to select all gvkey's you want to delete:
gvkey
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), ]