gadget-framework/mfdb

Negative queries

Closed this issue · 5 comments

bthe commented

Is there some way of asking for all data except for certain combinations. For example I would like to exclude a certain tow from the query as I now it is wrong/not representative. In dplyr I would simply use the filter command prior to further aggregation, but I'm not sure how I would do this using mfdb_sample...

Are you doing any other filtering on tow? If not I could make a function you could use like tow = mfdb_all_except('dodgy_tow'). Seems a bit special-purpose but quick to do. And anything else I can think of isn't much better than just listing the tows you do want instead.

bthe commented

I would guess that I would like to do something like defining fleets based on all gears except longline and gillnet (to take an actual example) so I like the mfdb_all_except approach, which I assume would link to the taxonomy tables.

Actually, I think mfdb_like and mfdb_not_like could be more useful. Where "like" is the SQL definition i.e. "GIL%".

bthe commented

That sounds ideal.

@bthe Do you want to take the above for a spin? I added like and not_like to mfdb_unaggregated, so you can do things like vessel_full_name = mfdb_unaggregated(not_like = c("%Mc%face", "Daw_")).

Using mfdb_unaggregated versus using any other function won't make a difference if it's not a column you are displaying. In theory we could also do something like mfdb_like_group(mc = "%Mc%face") if you need to group them together, but that's getting carried away for now.