I have the following dataframe (df) - more columns, but these are the corresponding columns:
ID Cost
1 $100
1 $200
2 $50
2 $0
2 $40
3 $10
4 $100
5 $0
5 $50
I would like to multiply this data file in such a way that if any of the costs for a specific ID = $ 0, then it should delete all these lines (i.e. all lines for this specific identifier).
Therefore, in this example, IDs 2 and 5 contain $ 0, so all lines of ID 2 and ID 5 must be deleted.
Here is the df result I would like:
ID Cost
1 $100
1 $200
3 $10
4 $100
Can anyone help with this? I tried some combinations of the function subset, but that didn't work.
** On a similar note: I have another dataframe with "NA" s - could you help me deal with the same problem if it were NA, not 0.
!