I need to merge two data frames: Complete10 and INSIDECostaRica. Inside Costa Rica contains a subset of the data in Complete10 that is the same but with some specific RICHNESS values changed from 0 to 0.5 (so that I can filter by these later). I tried merging them several ways, but it seems like the only way to keep my rows with 0.5 is to use all=TRUE, which means I end up with duplicates of these rows, a 0 row and a 0.5 row. I would like to use the distinct function to remove the rows with 0 values that are otherwise duplicated in a 0.5 row, but I think that will delete my 0.5 rows because my merge attached these values to the end of my dataset. For example, this is what my merge looked like, and this is what I have after the merge:
MergeTest<-merge(Complete10,INSIDECostaRica,by=c("GRID","x.centroids","y.centroids","RICHNESS"),all=TRUE)
GRID LONG LAT RICHNESS
75 5 6 0
75 5 6 0.5
76 8 4 12
77 2 7 0
78 4 3 0
78 4 3 0.5
And this is what I would like to have:
GRID LONG LAT RICHNESS
75 5 6 0.5
76 8 4 12
77 2 7 0
78 4 3 0.5
I don't want to remove all of the zeros from RICHNESS, just those that are duplicates of 0.5.