I have a data frame e.g.:
sub day
1 1
1 2
1 3
1 4
2 1
2 2
2 3
2 4
3 1
3 2
3 3
3 4
and I would like to remove specific rows that can be identified by the combination of sub and day.
For example say I wanted to remove rows where sub=’1′ and day=’2′ and sub=3 and day=’4′. How could I do this?
I realise that I could specify the row numbers, but this needs to be applied to a huge dataframe which would be tedious to go through and ID each row.
Or if sub is a factor as suggested by your use of quotes:
Could also use subset:
(And I endorse the use of
whichin Dirk’s answer when using “[” even though some claim it is not needed.)