selecting rows with unidentical values appearing in two different columns in R
- by bazon
Hi,
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!=dam2,] but could not work. dam1 and dam2 are dam or mother id's.
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
Thanks,
Bazon