selecting rows with unidentical values appearing in two different columns in R
Posted
by bazon
on Stack Overflow
See other posts from Stack Overflow
or by bazon
Published on 2010-05-19T06:26:22Z
Indexed on
2010/05/19
6:30 UTC
Read the original article
Hit count: 268
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
© Stack Overflow or respective owner