select rows with unidentical column values using R
- by Bazon
Hi Guys,
I need to create a new data frame that excludes dams that appear in "dam1" and
"dam2" columns on the same fosdate (fostering date). I tried df <- df[df$dam1!=df$dam2,] but did not work. Dam1 and dam2 are factors which are the ids's of mothers.
my df:
fosdate dam1 dam2
8/09/2009 2Z523 2Z523
30/10/2009 1W509 5C080
30/10/2009 1W509 5C640
30/10/2009 1W509 1W509
1/10/2009 1W311 63927
The new data frame that I need to get is:
dfnew:
fosdate dam1 dam2
30/10/2009 1W509 5C080
30/10/2009 1W509 5C640
1/10/2009 1W311 63927
Would appreciate any help!
Bazon